【发布时间】:2014-07-17 05:34:32
【问题描述】:
我正在使用 activeMQ 5.9。
我正在尝试在我的 activemq.xml 中实现一个拦截类型的路由,我在其中检查特定标头是否等于某个值,然后将其发送到不同的队列,否则允许它继续。
我正在关注这里的信息:http://activemq.apache.org/broker-camel-component.html
我的 camel.xml 文件如下所示:
<camelContext id="camel" trace="false" xmlns="http://camel.apache.org/schema/spring">
<route id="routeAboveQueueLimitTest">
<from uri="activemq:queue:do.something"/>
<choice>
<when>
<simple>${header.scope} == 'test'</simple>
<to uri="activemq:queue:test.do.something"/>
</when>
<otherwise>
<to uri="activemq:queue:do.something"/>
</otherwise>
</choice>
</route>
</camelContext>
然后,当我将消息放在“activemq:queue:do.something”上,标头名为 scope =“test”时,它会正确路由到“activemq:queue:test.do.something”队列。但是,当它没有该标头时,它会将其放回“activemq:queue:do.something”队列并一次又一次地处理它!
这似乎是合乎逻辑的,但上面的页面清楚地表明您必须将其显式发送回代理组件,页面上的第二个示例正好说明了这一点。
我意识到如果它没有标头,可以通过将其发送到不同的队列来解决此问题,但在此阶段这是不可取的。
【问题讨论】:
标签: apache-camel activemq