问题
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.
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>
I am not very familiar with queues or Camel so, sorry if this is a stupid question.
Thanks.
回答1:
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>
And then, in the route:
<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.
来源:https://stackoverflow.com/questions/20471455/apache-camel-resequencer-with-apache-camel-seda-queue