带有 Apache Camel SEDA 队列的 Apache Camel Resequencer? [英] Apache Camel Resequencer with Apache Camel SEDA queue?
问题描述
我有一个使用参数concurrentConsumers=5"的 SEDA 队列.现在,我试图将它与 Apache Camel Resequencer 集成,以便能够在处理消息之前重新排序消息,但是,当我这样做时,一次只处理一条消息.我想知道是否可以并行运行多个重新排序器消息.
I have a SEDA queue that uses the parameter "concurrentConsumers=5". Now, I am trying to integrate it with the Apache Camel Resequencer in order to be able to reorder the messages before processing them, however, when I do this, only one message is processed at a time. I would like to know if it is possible to run several resequencer messages in parallel.
这是我的 XML 代码:
This is my XML code:
<route>
<from uri="seda:barSetup?concurrentConsumers=5" />
<resequence>
<batch-config batchSize="300" batchTimeout="40000"
allowDuplicates="true"/>
<simple>in.header.priority</simple>
<to uri="exec:cat" />
<to uri="bean:batchjobMonitor" />
<to uri="log:output" />
</resequence>
</route>
我对队列或 Camel 不太熟悉,所以如果这是一个愚蠢的问题,抱歉.
I am not very familiar with queues or Camel so, sorry if this is a stupid question.
谢谢.
推荐答案
最后我没有使用重新排序器解决了这个问题.我使用了 PriorityBlockingQueueFactory 并在比较器中使用了与骆驼类似的重新排序器:
Finally I solved this not using the resequencer. I used the PriorityBlockingQueueFactory and in the comparator I use a similar resequencer to camel:
<bean id="priorityQueueFactory"
class="org.apache.camel.component.seda.PriorityBlockingQueueFactory">
<property name="comparator">
<bean class="com.sg.sgf.service.queues.MyExchangeComparator" />
</property>
</bean>
然后,在路线中:
<route>
<from uri="seda:priority?queueFactory=#priorityQueueFactory&size=100&concurrentConsumers=5&pollTimeout=10000" />
<!-- <resequence>
<batch-config batchSize="300" batchTimeout="40000"
allowDuplicates="true" />
<simple>in.header.priority</simple> -->
<to uri="exec:cat" /> <!-- the actual executable is set in the job that is passed to the queue -->
<to uri="bean:batchjobMonitor" />
<to uri="log:output" />
<!-- </resequence> -->
</route>
有了这个,我就有了我想要的.
With this, I have what I wanted.
这篇关于带有 Apache Camel SEDA 队列的 Apache Camel Resequencer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!