StasKolodyuk StasKolodyuk - 3 months ago 18
Java Question

Apache Camel. Throttle Part of the Route

I have a JMS queue. After receiving the message it needs to be stored to DB. Then depending on some condition I want send this message to third party service with fixed rate, so I use throttling.

I have the following route:

from("jms:queue")
.bean(persistingListener)
.choice()
.when(some condition ..)
.throttle(5)
.asyncDelayed()
.bean(thirdPartyServiceClient)
.endChoice();


However, the entire route gets throttled, not the part related to third party service client. I mean, that if I put 100 messages in the queue, only first 5 will be read. So, in this case the processing of messages that don't require third party service get delayed.

Any ideas on how to throttle only on the part related to third party service?

Thanks in advance

Answer

The JMS endpoint runs in a mode by default where each JMS message is processed in sequence. If you want to allow to process messages (out of order) due to asynchronous processing, then you need to enable this explict by configuring asyncConsumer=true on the endpoint.

See more details in the JMS documentation: http://camel.apache.org/jms

Comments