我正在尝试升级我们的一个应用程序的 Camel 版本。但我似乎无法再使用“transferExchange”选项通过 ActiveMQ/JMS 发送属性。
我写了一个小测试程序:
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
context.addComponent("test-jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
String JMS_URI = "test-jms:queue:test.queue?transferExchange=true";
from("direct:start")
.setProperty("some-string", constant("foo"))
.setProperty("some-date", body())
.to(JMS_URI);
from(JMS_URI)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("some-string: " + exchange.getProperty("some-string"));
System.out.println("some-date: " + exchange.getProperty("some-date"));
}
});
}
});
ProducerTemplate template = context.createProducerTemplate();
context.start();
template.sendBody("direct:start", new Date());
Thread.sleep(1000);
context.stop();
}
使用 Camel 2.15.2 时输出正确的值,但使用 2.18.3 时输出空值。
我怎样才能得到旧的行为?
最佳答案
Exchange 属性不再传播,并且您无法将其打开。将您的数据存储在消息 header 中。
关于apache-camel - ActiveMQ TransferExchange 不再在 Camel 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43756159/