Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

By default when a thread pool is to be created then its based on the default thread pool profile which is:

Code Block
xml
xml

    <threadPoolProfile id="defaultThreadPoolProfile" defaultProfile="true"
                       poolSize="10" maxPoolSize="20" maxQueueSize="1000" allowCoreThreadTimeOut="false"
                       rejectedPolicy="CallerRuns"/>

What that means is that for example when you use Multicast with parallelProcessing=true enabled, then it would create a thread pool based on the profile above. The rejectedPolicy has four options: Abort, CallerRuns, Discard, DiscardOldest which corresponds to the same four options provided out of the box in the JDK. Notice: option allowCoreThreadTimeOut is a new option from Camel 2.15 onwards.

You can define as many thread pool profiles as you like. But there must only one default profile. A custom thread pool profile will inherit from the default profile. Which means that any option you do not explicit define will fallback and use the option from the default profile.

...

Suppose you want to use a custom thread pool profile for a Multicast EIP pattern in a Camel route you can do it using the executorServiceRef attribute as shown:

Code Block
xml
xml

<camelContext ...>
    ...
    <threadPoolProfile id="fooProfile" 
                       poolSize="20" maxPoolSize="50" maxQueueSize="-1"/>
    ...

    <route>
       ...
       <multicast strategyRef="myStrategy" executorServiceRef="fooProfile">
          ...
       </multicast>
      ...
    <route>
</camelContext>

...

In Camel 2.11 onwards its easier to set the thread name pattern on the CamelContext using the threadNamePattern attribute in the XML files as shown below:

Code Block
xml
xml

  <camelContext xmlns="http://camel.apache.org/schema/spring" threadNamePattern="Riding the thread #counter#">
    <route>
      <from uri="seda:start"/>
      <to uri="log:result"/>
      <to uri="mock:result"/>
    </route>
  </camelContext>

...