0
我有很簡單的POJO類:Apache的駱駝:爲什麼我不能發送豆文字JMS
public class MessageBean {
String text;
public String getMessage()
{
return text;
}
}
和駱駝航線:
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();
}
}
我不明白爲什麼我不能從bean變量text
發送文本到activemq隊列?
當我嘗試從文件夾發送txt文件時,它正確發送到隊列中的jms。
你只需要使用ProducerTemplate發送消息踢的路線(它甚至可能是一個空的消息)。 – 2014-11-23 02:04:34