0
votes

I am trying to write a camel route that consumes incoming message from a JMS queue and handles them concurrently in different threads. The camel route I have got is like this:

<camel:endpoint id="requestQueue" uri="jms:queue.request" camelContextId="camel"/>
<camel:endpoint id="responseQueue" uri="jms:queue.response" camelContextId="camel"/>

<camel:camelContext id="camel">
    <camel:threadPool id="serviceThreadPool" poolSize="10" threadName="workerThread" maxPoolSize="20"/>

    <camel:route id="requestServingRoute">
        <camel:from ref="requestQueue"/>

        <camel:threads executorServiceRef="serviceThreadPool">
            <camel:to uri="bean:doSomething"/>
            <camel:to ref="responseQueue"/>
        </camel:threads>
    </camel:route>
</camel:camelContext>

However, what I can observe is that the incoming message is indeed handled by separate threads, but they are handled in a sequential order.

What I tried to achieve is that camel handles each request in the doSomething bean in separate threads for each incoming request.

How can I achieve this?

Thank you very much.

1

1 Answers

4
votes

You need to specify the number of concurrent consumers for the JMS request queue. See http://camel.apache.org/jms.html. You don't need to message around with the thread pools. eg in Java DSL syntax you would write something like:

from("jms:queue.request?concurrentConsumers=10")
.beanRef("bean", "doSomething")
.to("jms:queue.response)