Using custom thread pools

Usually when dealing with an EIP such as Splitter, Multicast, or Aggregator, the default pool of 10 threads that is created for the EIP is sufficient. However, each of these patterns allow you to provide a customized pool if this default pool is inadequate for your needs.

This recipe will outline how to define a custom thread pool in Camel.

Getting ready

The Java code for this recipe is located in the org.camelcookbook.parallelprocessing.threadpools package. The Spring XML files are located under src/main/resources/META-INF/spring and prefixed with threadPools.

How to do it...

To define a custom thread pool using the XML DSL, add a threadPool definition before any routes in the camelContext element:

<camelContext xmlns="http://camel.apache.org/schema/spring"> ...

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.