I have the below route and bean to get the message from the property file. In some message I have to replace the arguments in the message. Therefore I have looked for a solution without writing 2 methods in the bean one with arguments (getMessageWithArgs) and the second without arguments (getMessage).
Is it doable to get rid of getMessageWithArgs in the bean by using DSL in the route or to make the arguments in the getMessage optional so I have at the end one method in the bean?
Route
@Override
public void configure() throws Exception {
from("activemq:queue:1234")
.setHeader("functionId", simple(FUNCTION_ID))
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Message message = exchange.getIn();
message.setHeader("messageId", "notice_1234_error_messageBox_1");
// List<String> arguments = Arrays.asList("Test1", "Test2", "Test3");
// message.setHeader("arguments", arguments);
}
})
.setHeader("message").method("messageBean", "getMessage( ${header.functionId}, ${header.messageId})")
//.setHeader("message").method("messageBean", "getMessageWithArgs( ${header.functionId}, ${header.messageId}, ${header.arguments})")
.log("after calling getMessageWithoutValidation: ${body}");
}
Bean
@Component
public class MessageBean {
public String getMessage(@Header("functionId") String functionId,
@Header("messageId") String messageId) {
//Doing something to get the message
return message;
}
public String getMessageWithArgs(@Header("functionId") String functionId,
@Header("messageId") String messageId,
@Header("arguments") List<String> arguments) {
//Doing something to get the message
return message;
}
}