骆驼异步非阻塞组播

我有两个查询: 1.我们可以在骆驼中使用非阻塞的异步路由吗?我确实看到与seda异步,但是如果将工作卸载到其他阻塞的线程。 2.如果可以,我们可以在此类路由中使用多播。 以下是我的多步骆驼路线,该路线似乎有效。但不确定是异步还是非阻塞异步。

from("direct:multiStep")
             .to("bean:routeHandler?method=monoReturningMethod1")
             .process(new UnwrapStreamProcessor())
             .to("bean:routeHandler?method=monoReturningMethod2")
             .process(new UnwrapStreamProcessor())

以上工作正常,并且Web请求收到了monoReturningMethod的响应。在这种情况下,我要确保所有进程都不会阻塞。

对于多播,我正在尝试以下路由。不确定将UnwrapStreamProcessor放在哪里。我尝试将其放在end()之后,但是不起作用。我需要自定义的Processor吗?或者如何将所有Mono的退货捆绑在一起?

from("direct:incoming")
         .multicast()
         .parallelProcessing()
         .to("bean:routeHandler?method=monoReturningMethod1","bean:routeHandler?method=monoReturningMethod2")
         .end()

我正在使用带有弹簧启动启动器的apache`camel 3.0.1。

@Component("routeHandler")
public class RouteHandler {
     Mono<Entity> monoReturningMethod1(Exchange exchange) {
          //make some WebClient request which returns Mono.
     }
     Mono<Entity> monoReturningMethod2(Exchange exchange) {
          //make some WebClient request which returns Mono.
     }
}

此路由处理传入的Web请求。如何使所有路由处理无阻塞和异步。我尝试在process(new UnwrapStreamProcessor())之后使用monoReturningMehtod作为处理步骤,如果我按顺序进行,它可以工作。但是它不适用于多播,并且不允许覆盖原始消息。 有什么建议吗?

PS:我正在启动异步流程,如下所示: producerTemplate.asyncSend("RouteName",exchange)

yellowmin 回答:骆驼异步非阻塞组播

According to this page,异步路由引擎支持所有EIPs,但不是全部endpoint types (components)。一些组件仅具有有限的支持,即它们只能消耗或产生异步。

您可以在路由中使用Threads DSL来告诉骆驼,从现在开始,消息应该在新线程中异步路由。

本文链接:https://www.f2er.com/2589686.html

大家都在问