Apache Camel provide two solutions for using thread pool:
from("seda:stageName?concurrentConsumers=5").process(...)
and
from("direct:stageName").thread(5).process(...)
I would like to know, what is the difference between the two solutions ? Is it just two kind of write the same thing or not ? What are the use cases ?
The seda: component provides asynchronous SEDA behavior so that messages are exchanged on a BlockingQueue and consumers are invoked in a separate thread to the producer.
The direct: component provides direct, synchronous invocation of any consumers when a producer sends a message exchange. This endpoint can be used to connect existing routes or if a client in the same JVM as the router wants to access the routes.
The thread pool is a pool that dynamically can increase/shrink at runtime depending on load, the concurrent consumers is always fixed.
Like, in your case,
For Concurrent consumers - from("seda:stageName?concurrentConsumers=5").process(...)
For Thread Pool - from("direct:stageName").thread(5).process(...)
Now,if you always want to have 5 threads available then use Concurrent Consumers and if you want the threads to be available as per the load(but not more than 5) 
then use Thread Pool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With