Camel parallel processing options

◇◆丶佛笑我妖孽 提交于 2019-12-05 00:24:27

问题


I am working on Camel routes in RedHat Fuse Service Works which has Camel 2.10.

I would like to know the differences between the following implementations:

1/ using SEDA routes

    from("A")
    .split(body())
    .to("seda:B");

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

2/ using parallel processing

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

3/ using threads

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

From what I've seen the method 3 (threads) allows to configure the thread pool size which seems the same as "concurrentConsumers" of solution 1 (SEDA).

If I don't pass any parameters to the method thread will the behavior of methods 2 and 3 be the same ?

Thanks in advance,

Regards


回答1:


You can setup the thread number in 1), 3), but 1) can still receive the message from other route which just like from(xxx).to("seda:B"). 2) You need to setup the ExecutorService (or ThreadPool), otherwise the parallelProcessing won't work as you want.




回答2:


Below is the working sample code :

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()


来源:https://stackoverflow.com/questions/26736099/camel-parallel-processing-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!