How can we process direct-vm asynchronously?
I have the following Camel routes definition:
<route id="routeA">
<from uri="activemq:queue:queueA" />
<to uri="direct-vm:someProcessing" />
<to uri="direct-vm:processAsync" />
</route>
<route id="routeB">
<from uri="direct-vm:processAsync">
<threads executorServiceRef="someRef">
<inOnly uri="direct-vm:timeTakingRoute" />
<threads>
<route>
When queue consumer consumes message and sends to routeB and calls direct-vm:timeTakingRoute using threads DSL, caller thread which is queueA still waits until thread created using thread DSL completes.
How can we process this asynchronously (Caller thread should not wait until thread created using thread DSL completes)?
Direct component is designed to be synchronous http://camel.apache.org/direct-vm.html
Please try to use seda instead:
<route id="routeA">
<from uri="activemq:queue:queueA" />
<to uri="direct-vm:someProcessing" />
<inOnly uri="seda:processAsync" />
</route>
<route id="routeB">
<from uri="seda:processAsync" />
<to uri="direct-vm:timeTakingRoute" />
</route>
You can either choose seda or vm component.
When using seda, note that queues are only visible within a it's CamelContext.
If you want inter-communication between CamelContext, use vm component, which is an extension to seda component.
Read more: seda vm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With