2 骆驼路线消耗相同的队列
2 Camel routes consume same Queue
我已经在该地址中创建了多播地址 FROM.TEXT 和任播队列 FROM.TEXT。将此队列配置为具有 max-consumers="10".
<address name="FROM.TEXT">
<multicast>
<queue name="FROM.TEXT" max-consumers="10">
<durable>true</durable>
</queue>
</multicast>
</address>
我创建了 2 个 Camel 路由,它们将使用来自该队列的消息并路由到 2 个不同的队列:
public void configure() throws Exception {
InitialContext context = new InitialContext();
from("jms:FROM.TEXT")
.routeId("route1")
.autoStartup(true)
.convertBodyTo(String.class, "UTF-8")
.to("jms:QUEUE1");
getContext().start();
}
当我启动 route1 时,它的工作是为队列创建一个使用者,但是当我启动 route2 时,没有任何反应。我需要这样做,因为同一条消息必须路由到 2 个不同的队列。
谢谢。
如果您希望连接到目标的任何客户端都获得相同的消息,那么您应该使用 JMS 主题。只需定义一个支持多播的地址:
<address name="FROM.TEXT">
<multicast/>
</address>
那么你的路线应该是这样的:
public void configure() throws Exception {
InitialContext context = new InitialContext();
from("jms:topic:FROM.TEXT")
.routeId("route1")
.autoStartup(true)
.convertBodyTo(String.class, "UTF-8")
.to("jms:queue:QUEUE1");
getContext().start();
}
您可以这样定义 to
队列:
<address name="QUEUE1">
<anycast>
<queue name="QUEUE1">
</anycast>
</address>
我已经在该地址中创建了多播地址 FROM.TEXT 和任播队列 FROM.TEXT。将此队列配置为具有 max-consumers="10".
<address name="FROM.TEXT">
<multicast>
<queue name="FROM.TEXT" max-consumers="10">
<durable>true</durable>
</queue>
</multicast>
</address>
我创建了 2 个 Camel 路由,它们将使用来自该队列的消息并路由到 2 个不同的队列:
public void configure() throws Exception {
InitialContext context = new InitialContext();
from("jms:FROM.TEXT")
.routeId("route1")
.autoStartup(true)
.convertBodyTo(String.class, "UTF-8")
.to("jms:QUEUE1");
getContext().start();
}
当我启动 route1 时,它的工作是为队列创建一个使用者,但是当我启动 route2 时,没有任何反应。我需要这样做,因为同一条消息必须路由到 2 个不同的队列。
谢谢。
如果您希望连接到目标的任何客户端都获得相同的消息,那么您应该使用 JMS 主题。只需定义一个支持多播的地址:
<address name="FROM.TEXT">
<multicast/>
</address>
那么你的路线应该是这样的:
public void configure() throws Exception {
InitialContext context = new InitialContext();
from("jms:topic:FROM.TEXT")
.routeId("route1")
.autoStartup(true)
.convertBodyTo(String.class, "UTF-8")
.to("jms:queue:QUEUE1");
getContext().start();
}
您可以这样定义 to
队列:
<address name="QUEUE1">
<anycast>
<queue name="QUEUE1">
</anycast>
</address>