有什么区别&QUOT的差异; SEDA + concurrentConsumers"和"直接+线程" [英] What is the difference between "seda + concurrentConsumers" and "direct + threads"

查看:156
本文介绍了有什么区别&QUOT的差异; SEDA + concurrentConsumers"和"直接+线程"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache的骆驼使用线程池提供了两种解决方案:

Apache Camel provide two solutions for using thread pool:

从(SEDA:艺名concurrentConsumers = 5)。工艺(...)

从(直接:艺名)线程(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 ?

推荐答案

SEDA:组件规定,这样的消息在交换的BlockingQueue和消费者都在一个单独的线程生产者异步调用行为SEDA

SEDA Component

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.

直接:组件提供任何消费者的直接同步调用,当制片人发送消息交换。此端点可以用于现有的线路连接,或者在同一个JVM客户端的路由器要访问的路线。

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.

一样,你的情况,

对于并发消费者 - 从(SEDA:艺名concurrentConsumers = 5)。工艺(...)

线程池 - 从(直接:艺名)线程(5).process(...)

现在,如果你总是希望有5个线程可用然后用并发消费者,如果你想线程可用按照负载(但不超过5 )
然后用线程池

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.

这篇关于有什么区别&QUOT的差异; SEDA + concurrentConsumers"和"直接+线程"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆