Apache Camel:直接端点 运行 可以并行路由吗?

Apache Camel: can a direct endpoint run routes in parallel?

在我的 Camel 应用程序中,有 2 个 CXF 端点由相同的处理路由处理,据我所知,每个端点可能会根据传入的 HTTP 请求并行生成交换。
两个端点使用 direct: 组件通过同一路由转发请求,有时将其描述为 调用方法 .

的 Camel 等价物

The direct: component provides direct, synchronous invocation of any consumers when a producer sends a message exchange.

我的问题:

这是我的情况:

<route id="CxfRoute1">
    <from uri="cxf:bean:endpoint1" />
    <to uri="direct:handle" />
</route>

<route id="CxfRoute2">
    <from uri="cxf:bean:endpoint2" />
    <to uri="direct:handle" />
</route>

<route id="HandleStuffRoute" />
    <from uri="direct:handle" />
    <to uri="bean:stuffHandler" />
</route>

在你的情况下是的,它应该 运行 并行处理不同的请求。

您或许可以创建一个 Camel 单元测试来对此进行测试。在您的路线测试中 class 您可以创建一个基于计时器的新路线,然后创建一些虚拟主体并像这样调用您的路线端点:

 .parallelProcessing().to("cxf1", "cxf2", "cxf3")

然后观察结果

我想另一种方法是使用 JMeter 并针对您的 cxf 端点创建测试并观察。

它的工作方式类似于直接方法调用,例如 Foo foo = ... ; foo.callSomeMethod() 即使用当前线程调用。因此,在此示例 CXF 中,您从消费者获得并行,因此,如果 2+ 个客户端同时调用 CXF,则每个客户端都在其自己的线程中调用 运行s,并且它们中的每一个都调用直接作为直接方法调用,并且所有可以 运行 并行。

为了以与使用直接相同的方式处理并行请求,您可以改用 "seda"。 http://camel.apache.org/seda

中的详细信息