Camel并行处理选项



我在RedHat Fuse Service Works的Camel路由上工作,该服务有Camel 2.10。

我想知道以下实现之间的区别:

1/使用SEDA路线

    from("A")
    .split(body())
    .to("seda:B");
    from("seda:B?concurrentConsumers=4")
    .routeId("MySEDATestRoute")
    .to("C")
    .end();

2/使用并行处理

   from("A")
    .split(body())
    .parallelProcessing()
    .to("C");

3/使用线程

    from("A")
    .split(body())
    .threads()
    .to("C");

根据我所看到的,方法3(线程)允许配置线程池大小,这似乎与解决方案1(SEDA)的"concurrentConsumers"相同。

如果我不向方法线程传递任何参数,方法2和3的行为会相同吗?

提前感谢

问候

您可以在1)、3)中设置线程号,但1)仍然可以从其他路由接收消息,就像从(xxx).to("seda:B")一样。2) 您需要设置ExecutorService(或ThreadPool),否则并行处理将无法正常工作。

下面是工作示例代码:

CamelContext context = getContext();
ExecutorService service = new ThreadPoolBuilder(context).poolSize(10).maxPoolSize(150).maxQueueSize(150).build("CustomPool");
from("properties:{{file.fromLocation}}")
    .log("Received the file...")
    .split().tokenize("n").executorService(service)
    .streaming()
    .parallelProcessing()

最新更新