Apache camel Apache Camel是否支持activemq通配符使用者?
我需要一种方法来使用来自多个activemq jms队列的消息 根据activemq文档,它支持 我正在使用camel作为消息传递总线。是否可以查看下面的命名队列Apache camel Apache Camel是否支持activemq通配符使用者?,apache-camel,activemq,wildcard,consumer,Apache Camel,Activemq,Wildcard,Consumer,我需要一种方法来使用来自多个activemq jms队列的消息 根据activemq文档,它支持 我正在使用camel作为消息传递总线。是否可以查看下面的命名队列 aaa.processQueue bbb.processQueue ccc.processQueue 通过配置驼峰路由查看activemq:*.processQueue端点 如果有更清洁的替代品,也请告诉我。是。这应该是可行的,因为Camel正在使用OpenWire/JMS客户机 你的选择是: from(“activemq:.pro
aaa.processQueue
bbb.processQueue
ccc.processQueue
通过配置驼峰路由查看activemq:*.processQueue
端点
如果有更清洁的替代品,也请告诉我。是。这应该是可行的,因为Camel正在使用OpenWire/JMS客户机 你的选择是:
from(“activemq:.processQueue”)
from(“activemq:aaa.processQueue、bbb.processQueue、ccc.processQueue”)
from("activemq:aaa.processQueue").to("direct:doProcess");
from("activemq:bbb.processQueue").to("direct:doProcess");
from("activemq:ccc.processQueue").to("direct:doProcess");
from("direct:doProcess").whatever..
通过这种方式,您可以轻松地打开/关闭路由以及为一个路由分配更多的使用者,因为您需要对aaa.processQueue
消息具有比其他消息更高的优先级他们在github上有一个使用通配符的routebuilder示例:
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
// use wildcard to consume from all sports
from("activemq:queue:sport.>")
.to("log:received?showHeaders=true")
.choice()
// the JMSDestination contains from which queue the message was consumed from
.when(header("JMSDestination").isEqualTo("queue://sport.pl.chelsea"))
.to("mock:chelsea")
// we can use a reg exp to match any message from 1st division
.when(header("JMSDestination").regex("queue://sport.1st.*"))
.to("mock:1st")
.otherwise()
.to("mock:other")
.end();
}
};
}
Ref:我不知道通配符是否有效,但如果不行,您可以定义多个路由,每个路由使用同一处理器从不同队列读取数据。虽然这取决于您事先知道队列的名称和数量。如果有人将消息发送到aaa.processQueue或bbb.processQueue,我们如何区分消息是发送到aaa.processQueue还是bbb.processQueue?那么如果需要将它们分开,为什么要使用通配符?在我的应用程序中,我使用的通配符如下:*.processQueue;但在发送消息时,我将发送到{uniqueId}.processQueue。我需要在bean或处理器中获得唯一ID;我可以这样做吗?这本质上是另一个问题,但您可以随时查看消息的
JMSDestination
属性。他们的github上有一个示例: