I have very simple pojo class:
public class MessageBean {
String text;
public String getMessage()
{
return text;
}
}
And camel route:
public static void main(String[] args) {
final MessageBean bean = new MessageBean();
bean.text = "This is the text";
CamelContext context = new DefaultCamelContext();
ConnectionFactory conFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61616");
context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(conFactory));
try {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:hello").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(bean);
}
}).setBody(simple("${body.message}")).to("jms:queue:Test.Queue");
}
});
} catch (Exception e) {
e.printStackTrace();
}
try {
context.start();
Thread.sleep(5000);
context.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
I don't understand why I can not send text from bean variable text to activemq queue??
When I try to send from folder the txt file it sends correctly to the queue in jms.