we had requirement process multiple tasks concurrently , each of these tasks takes 10 sec complete processing. our camel routes looks this.
<route id="routea"> <from uri="activemq:queue:queuea" /> <to uri="direct-vm:genericprocessing" /> </route> <routeid="routeb"> <from uri="activemq:queue:queueb" /> <to uri="direct-vm:genericprocessing" /> </route> <route id="routec"> <from uri="direct-vm:genericprocessing" /> <!--run business rules --> <inonly uri="vm:timetakingroute" /> <!-- takes 10 sec complete /> </route>
from vm:timetakingroute request should run in single thread requires db transactions.if use inonly exchange pattern vm endpoint, request runs asynchronously request takes minimum of 10 sec process here, other request might pile untill 1st request completes. how can spawn threads run requests concurrently. possibles options can think off having concurrentconsumers option on vm, replacing vm activemq concurrent consumers defined, replace vm wiretap custom threadpool or define below?
<threads> <to uri="vm:timetakingroute" /> </threads>
what best possible option solve this?
generally increase consumer threads reading queues using maxconcurrentconsumers property...this multi-threads downstream processing
<route id="routea"> <from uri="activemq:queue:queuea?maxconcurrentconsumers=10" /> <to uri="direct-vm:genericprocessing" /> </route>
other options
use async api inonly operations not block client call
use concurrentconsumers on vm component (as suggested)
add queue hop decouple/multi-thread (seda, activemq) downstream in-only process
Comments
Post a Comment