javaapache-camelintegrationeip

Block route until consumer receives message


I have a route like this:

[producer1]--->[blocker]--->                 
                           |--->[aggregator]---> [consumer]
[producer2]---------------->

Producer1 and producer2 are pushing messages to the aggregator. If there are two messages with the same id then the aggregation is completed and the aggregated message will be routed to a consumer.

Is it possible to block the route after the producer1 sends a message to the aggregator? Something like wait until the consumer receives the aggregated message.


Solution

  • No this is not possible as the aggregator is two-legged. So what goes out of the aggregator is not linked to what goes in.

    You can however build a java bean and use a CountDownLatch and then block after you have called the aggregator, and then signal a count down when you have an outgoing message from the aggregator.