Reputation: 655
I've created multicast Address FROM.TEXT and an Anycast Queue FROM.TEXT inside this address. Configured this queue to have max-consumers="10".
<address name="FROM.TEXT">
<multicast>
<queue name="FROM.TEXT" max-consumers="10">
<durable>true</durable>
</queue>
</multicast>
</address>
I created to 2 Camel routes that will consume messages from this queue and route to 2 different queue:
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();
}
When I started the route1, its work, create a consumer for the queue, but when I start the route2, nothing happens. I need to this because the same message has to route to 2 different queues.
Thanks.
Upvotes: 0
Views: 573
Reputation: 35207
If you want any client connected to the destination to get the same message then you should use a JMS topic. Just define an address supporting multicast:
<address name="FROM.TEXT">
<multicast/>
</address>
Then you're route would be something like:
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();
}
You'd define your to
queue like this:
<address name="QUEUE1">
<anycast>
<queue name="QUEUE1">
</anycast>
</address>
Upvotes: 1