Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request only messaging with direct-vm in camel routes

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)?

like image 507
Mr9 Avatar asked Jan 02 '26 02:01

Mr9


2 Answers

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>
like image 107
cslysy Avatar answered Jan 04 '26 12:01

cslysy


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

like image 36
Jayarajan Avatar answered Jan 04 '26 11:01

Jayarajan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!