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 under src/main/resources/META-INF/spring
and prefixed with threadsDsl
.
This recipe assumes you are starting with a route that starts on a single thread, such as when consuming using the Direct Component, and you want to use a pool of threads for some...