You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Threading Model

This information applies from Camel 2.3 onwards

The threading model in Camel is based on leveraging the JDK concurrency API which provides thread pools, named ExecutorService.

Camel leverages thread pools in the following places:

  • several EIP patterns supports using thread pools for concurrency
  • SEDA component for asynchronous connectivity
  • Threads DSL in the Camel route
  • ServicePools for pooling services
  • And some component provide thread pools by nature such as JMS, Jetty

Thread pool profiles

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

    <threadPoolProfile id="defaultThreadPoolProfile" defaultProfile="true"
                       poolSize="10" maxPoolSize="20" maxQueueSize="1000"
                       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 have four options: Abort, CallerRuns, Discard, DiscardOldest which corresponds to the same four options provided out of the box in the JDK.

In Java DSL you can configure the default thread pool profile from the ExecutorServiceStartegy which you access from CamelContext.

Management

All the thread pools that Camel creates are managed and thus you can see them in JConsole under the threadpools category.

ExecutorServiceStrategy

Camel provides a pluggable strategy to hook in your own thread pool provider, for example from a WorkManager in a J2EE server etc.
See the org.apache.camel.spi.ExecutorServiceStrategy interface which you should implement and hook into the WorkManager.

See [Advanced XXX config}} for how to configure it.

You can configure it on the CamelContext from Java DSL using the getter/setter.

See Also

  • No labels