骆驼动态路由无限EN-消息队列
结果
我的工作骆驼的动态路由器派生并派遣相关的队列通过参考的http://骆驼。 apache.org/dynamic-router.html 结果
以下是骆驼配置XML:
Following is the camel config xml:
<route id="dynamicRouter" autoStartup="true">
<from uri="vm://service1?concurrentConsumers=10&timeout=0" />
<choice>
<when>
<simple>${body.documentStatus} == 'SUCCESS' </simple>
<log message="routing to dynamic router" />
<dynamicRouter>
<!-- use a method call on a bean as dynamic router -->
<method ref="messageRouter" method="route" />
</dynamicRouter>
</when>
</choice>
</route>
以下是我的动态路由器豆:结果
Following is my dynamic router bean:
公共类MessageRouter {
public class MessageRouter {
private static final String QUEUE_BROKER = "activemq";
private static final String DEFAULT_QUEUE = "queue";
/**
*
* @param obj
* message
* @return the dynamically generated queue name
*/
public String route(ServiceObject obj) {
RecordObject record = obj.getRecordObject();
if(record != null){
return QUEUE_BROKER + ":"
+ record.getId() + "." + DEFAULT_QUEUE;
}
return null;
}
}结果
我能够带连接队列中的消息中动态创建的队列中,但消息被越来越无限排队。结果任何帮助识别可能是什么原因会是很大的帮助。
I am able to en-queue messages in dynamically created queue but messages are getting enqueued infinitely.
Any help in identifying what could be the reason would be of great help.
在此先感谢!
在
- http://camel.apache.org/dynamic-router.html
和看到提防盒子,它说的方法必须返回空
信号的动态路由器爆发。
And see the beware box, it says the method must return null
to signal to the dynamic router to break out.
所以在上面的code,那么这code线
So in your code above, then this code line
RecordObject record = obj.getRecordObject();
...的记录
对象从来都不是空
,因此动态路由器保持持续下去。
... the record
object is never null
and therefore the dynamic router keeps going forever.
如果你只想要这个动态路由的一次的再使用动态RECEIPIENT列表EIP代替,见
If you only want this dynamic routing one time then use the dynamic receipient list eip instead, see
- http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html
- http://camel.apache.org/recipient-list.html
和你的XML路线
<recipientList>
<!-- use a method call on a bean as dynamic router -->
<method ref="messageRouter" method="route" />
</recipientList>