Processing split messages in parallel
When building integrations, it is often necessary to increase the throughput of a route. Short of speeding up the individual steps, which may not always be possible, one of the most convenient ways to do this is to process portions of the route in parallel. This recipe will show how you can use the Splitter EIP's parallel processing option to hand off message fragments to a pool of threads for concurrent processing.
Getting ready
Java code for this recipe is located in the org.camelcookbook.splitjoin.split
package. Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with splitParallel
and splitExecutorService
.
How to do it...
To process split messages through the route in parallel, set the parallelProcessing
attribute to true
on the split
statement:
In the XML DSL, this is written as:
<from uri="direct:in"/>
<split parallelProcessing="true">
<simple>${body}</simple>
<log message="Processing message...