【发布时间】:2014-10-19 00:43:52
【问题描述】:
我有一个场景,我得到消息 A 作为输入。然后消息 A 必须拆分为 3 种不同类型的消息,并转发到其他路由。重要的是消息以精确的顺序到达,即。 A-1 必须在 A-2 之前发送,A-2 必须在 A-3 之前发送。
为此,我做了以下(大纲):
from("activemq:queue:somequeue-local")
.multicast().to("direct:a1","direct:a2","direct:a3");
from("direct:a1)
//split incoming message and prepare output document for A-1
.to("activemq:queue:otherqueue")
.from("direct:a2)
//split incoming message and prepare output document for A-2
.to("activemq:queue:otherqueue")
.from("direct:a3)
//split incoming message and prepare output document for A-3
.to("activemq:queue:otherqueue")
在另一种情况下,负责将信息发送到外部系统,我有
.from("activemq:queue:otherqueue?maxMessagesPerTask=1&concurrentConsumers=1&maxConcurrentConsumers=1")
// do different stuff based on which type we are called with then end with
.beanref("somebean","writeToFileAndCallImportbat");
现在,我的问题是,当我到达接收者时,我会以随机顺序收到消息。有时是 A-1,A-3,A-2,有时是正确的,A-1,A-2,A-3。
我尝试将 JMSXGroupID 和 JMSXGroupSeq 添加到消息中,但没有任何运气。
我也尝试过完全跳过 MQ 部分,并使用 direct-vm: 调用共享接收器,但看起来我一次同时调用了三个接收器,并且仍然以随机执行顺序。
我的印象是多播会按顺序运行,除非另有提示?
所采用的方法是否存在根本问题?
我使用的是 Camel 2.12 版。
或者,更直白地说:
- 我想要一个创建三个不同输出消息并按顺序在它们上执行批处理文件的路由。我该怎么做?
【问题讨论】:
标签: apache-camel activemq multicast