StasKolodyuk StasKolodyuk - 1 year ago 50
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:

.when(some condition ..)

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 Source

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: