Camel threads(1,10) processor only holds 1 thread in its threadpool and does not grow.

Solution Verified - Updated -

Environment

  • Camel 2.10.0.fuse-71-047

Issue

  • the camel thread pool does not grow in size. It appears to keep the "core size" number of threads in the pool.

Resolution

Why isn't my thread pool growing to maxpoolsize?

The Camel threads processor is delegating to the java.util.concurrent.ThreadPoolExecutor. The ThreadPoolExecutor poolsize is controlled by the interaction of corePoolSize, maximumPoolSize AND the QueueSize. From the javadoc for ThreadPoolExecutor (http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html) explains it best:


Queuing Any BlockingQueue may be used to transfer and hold submitted tasks. The use of this queue interacts with pool sizing: - If fewer than corePoolSize threads are running, the Executor always prefers adding a new thread rather than queuing. - If corePoolSize or more threads are running, the Executor always prefers queuing a request rather than adding a new thread. - If a request cannot be queued, a new thread is created unless this would exceed maximumPoolSize, in which case, the task will be rejected.

By default the Camel Threads component maxQueuesize is 1000.

It is possible to change the maxQueueSize as follows

.threads(1,10,"vm1").maxQueueSize(1)

There are also other approaches to changing the the configuration of the thread pools used within camel by using the "default thread pool profile" or using a custom thread pool. These are all explained in http://fusesource.com/docs/esbent/7.1/camel_eip/BasicPrinciples-Thread.html

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.