Spreading the load within a route using a set of threads

Not all Camel components support specifying multiple consumers (threads) processing messages concurrently (see the Increased message consumption through multiple endpoint consumers recipe). Routes that use consuming endpoints, such as direct: or file:, default to using a single thread to process the message. This recipe will show you how to get around this constraint, by using the threads DSL to pass messages that were originally consumed sequentially, for example using direct:, to a thread pool so that they can now be processed in parallel.

Getting ready

The Java code for this recipe is located in the org.camelcookbook.parallelprocessing.threadsdsl package. The Spring XML files are located ...

Get Apache Camel Developer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.