gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 01:24:41 24 4
gpt4 key购买 nike

我有一对 Camel 路由,它们从两个不同的队列接收消息,其进程由同一个 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,它可以并行处理。只需确保它不存储任何状态信息,这实际上是建议的最佳实践之一(下面的链接)。

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

关于java - Camel 中的两条路由是否引用同一个处理 bean 并行执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57113754/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com