Apache Camel Resequencer with Apache Camel SEDA queue?

六月ゝ 毕业季﹏ 提交于 2019-12-11 08:23:21

问题


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&amp;size=100&amp;concurrentConsumers=5&amp;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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!