本文介绍了apache camel-seda端点多播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

from("seda:start)
.multicast(new GroupedBodyAggregationStrategy())
      .parallelProcessing()
      .to("seda:process1", "seda:process2")
      .end()
   .to("seda:join");

该计划使process1和process2并行运行,并且其输出在连接端点上可用.如果在"direct"上,上面的方法工作正常,但是在"seda"上的行为是即使process1和process2仍在进行中,"join"也被立即调用.

The plan is for process1 and process2 to run in parallel and for its output to be available on join endpoint.Above is working fine if on "direct", but on "seda" the behavior is that the "join" is getting invoked immediately even though process1 and process2 is still in progress.

我尝试将以下选项添加到process1和process2:

I have tried adding the following options to process1 and process2:

to("seda:process1?waitForTaskToComplete=Always", "seda:process2?waitForTaskToComplete=Always")

现在一切正常(我可以在连接端点上检索process1和process2输出),但是整个请求链正在排队并且没有并行运行.例如,我在开始"端点上并行发送了两条消息,一个完整的链只有在另一个完整的链完成后才被触发.

It is now behaving okay (I can retrieve process1 and process2 outputs on join endpoint) but one whole chain of request is getting queued and not running in parallel. Example, I have sent two messages in parallel on "start" endpoint, one whole chain is getting triggered only after having the other the other full chain is completed.

有什么想法吗?

推荐答案

您可以使start和join组件使用seda.而process1和process2将multicastparalellProcessing结合使用,这将负责并行运行这些进程.

You can make the start and join component use seda. whereas the process1 and process2 uses multicast with paralellProcessing which will take care of running these process in parallel.

对于seda:start,使用类似

from("seda:start?concurrentConsumers=10"),这将开始并行接受10个请求.有关更多信息,请查看 http://camel.apache.org/seda.html

from("seda:start?concurrentConsumers=10") this will start accepting 10 requests in parallel. For more information, please take a look at http://camel.apache.org/seda.html

这篇关于apache camel-seda端点多播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-27 18:10