在 Camel 中有两条路由引用同一个处理 bean 是否并行执行?

Does having two routes in Camel reference the same processing bean execute in parallel?

我有一对骆驼路线,它们从两个不同的队列接收消息,其进程由同一个 bean 执行(通过引用)。这是通过 Spring & Camel XML.

完成的

配置如下:

<route id "route-1" xmlns="http://camel.apache.org/schema/spring">
    <from uri="queue:IN1" />
    <process ref = "myProcessBean />
</route>
<route id "route-2" xmlns="http://camel.apache.org/schema/spring">
    <from uri="queue:IN2" />
    <process ref = "myProcessBean />
</route>

如果我在 IN1 和 IN2 上都收到消息,这些消息会被并行处理吗?

是的。处理器是一个单例 bean,它可以并行处理。只需确保它不在其中存储任何状态信息,这实际上是建议的最佳实践之一(Link 下面)。

https://www.3riverdev.com/apache-camel-processors-should-never-be-stateful/