apache-camel - ActiveMQ TransferExchange 不再在 Camel 中工作?

标签 apache-camel activemq

我正在尝试升级我们的一个应用程序的 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/

相关文章:

java - 如何从java异步发送soap消息

java - 使用 Eclipse 创建 Camel 项目

java - Apache Camel 在使用quartz 调度程序调度 ftp 端点时抛出 java.lang.NullPointerException

java - 使用apache Camel从队列到soap服务器的数据传输

java - 在JMS/ActiveMQ中如何使用同步来保持MessageConsumer的存活?

activemq - 什么是 MQ?为什么要使用它?

java - JBoss Fuse,使用 ActiveMQ 创建容器

java - 在 Apache Camel RouteBuilder 配置中,.id() 和 .routeId() 有什么区别

java - Apache Camel Multipart Netty Rest DSL 不适用于camel-jackson 依赖项

java - 检测 ActiveMQ 主题的使用者的变化