Pit*_*ith 5 java multithreading apache-camel threadpool
Apache Camel提供了两种使用线程池的解决方案:
from("seda:stageName?concurrentConsumers=5").process(...)
和
from("direct:stageName").thread(5).process(...)
我想知道,两种解决方案有什么区别?它只是两种写同样的东西吗?有什么用例?
所述seda: component提供异步SEDA行为,以便消息是在交换的BlockingQueue和消费者在一个单独的线程来生产者调用.
在direct: component提供时,生产者发送一个消息交换的任何消费者的直接的,同步调用.此端点可用于连接现有路由,或者与路由器在同一JVM中的客户端要访问路由.
线程池是一个可以在运行时根据负载动态增加/缩小的池,并发消费者始终是固定的.
就像,在你的情况下,
对于Concurrent消费者 - 来自("seda:stageName?concurrentConsumers = 5").process(...)
对于线程池 - 来自("direct:stageName").thread(5).process(...)
现在,如果您总是希望有5个线程可用,那么请使用Concurrent Consumers,如果您希望线程按负载可用(但不超过5个),那么请使用Thread Pool.
| 归档时间: |
|
| 查看次数: |
3680 次 |
| 最近记录: |