Apache Camel中的多播

huangapple go评论74阅读模式
英文:

Multicast in Apache Camel

问题

I'm newbie in Apache Camel, so please forgive me for the stupid question.
我是Apache Camel的新手,所以请原谅我这个愚蠢的问题。

I am browsing examples of sending messages using multicast and I don't understand it.
我正在浏览使用多播发送消息的示例,但我不理解。

I know that (in the network layer) multicast source sends datagram to specified address from range 224.0.0.0 to 239.255.255.255, to subscribers, but multicast source "does not know" how many subscribers are, only one datagram is sent for anyone of subscribers .
我知道(在网络层面上)多播源将数据报发送到从224.0.0.0到239.255.255.255范围内的指定地址,发送给订阅者,但多播源“不知道”有多少订阅者,只发送一个数据报给任何一个订阅者。

I do not understand either the example from the documentation (https://camel.apache.org/components/latest/eips/multicast-eip.html#_multicast_example) or from here (https://www.javarticles.com/2015/05/apache-camel-multicast-examples.html).
我不理解文档(https://camel.apache.org/components/latest/eips/multicast-eip.html#_multicast_example)中的示例,也不理解这里(https://www.javarticles.com/2015/05/apache-camel-multicast-examples.html)的示例。

Why (if I understood correctly) the subscribers of the message are explicitly specified ("direct: a", "direct: b", "direct: c")?
为什么(如果我理解正确的话),消息的订阅者被明确指定为("direct: a", "direct: b", "direct: c")?

After all, in one moment there may be 3 of them, in another time 10 of them, and so on. I don't think I need to change the code and define e.g. "direct:10", am I right?
毕竟,在某一时刻可能有3个,另一时刻可能有10个,等等。我认为我不需要改变代码并定义例如*"direct:10"*,我是对的吗?

Does the Apache Camel multicast mean something different than the one from the network layer?
Apache Camel的多播是否与网络层的多播意思不同?

英文:

I'm newbie in Apache Camel, so please forgive me for the stupid question.
I am browsing examples of sending messages using multicast and I don't understand it.

I know that (in the network layer) multicast source sends datagram to specified address from range 224.0.0.0 to 239.255.255.255, to subscribers, but multicast source "does not know" how many subscribers are, only one datagram is sent for anyone of subscribers .

I do not understand either the example from the documentation (https://camel.apache.org/components/latest/eips/multicast-eip.html#_multicast_example) or from here (https://www.javarticles.com/2015/05/apache-camel-multicast-examples.html).
Why (if I understood correctly) the subscribers of the message are explicitly specified ("direct: a", "direct: b", "direct: c")?
After all, in one moment there may be 3 of them, in another time 10 of them, and so on. I don't think I need to change the code and define e.g. "direct:10", am I right?

Does the Apache Camel multicast mean something different than the one from the network layer?

答案1

得分: 1

是的,它们不同。多播 EIP 是一种将消息同时发送给 N 个接收者的方法(接收者数量在事先固定/已知)。

英文:

Yes its not the same. Multicast EIP is a way of sending a message to N recipients at the same time (where the number of recipient is fixed/known ahead of time).

答案2

得分: 1

是的,你正确理解了网络层组播和Apache Camel组播之间的区别。

Camel组播的用例是当你想要将相同的消息发送到多个端点时。所以在文档示例中:

from("direct:a").multicast().to("direct:x", "direct:y", "direct:z");

来自"direct:a"的相同的消息将被发送到所有三个端点。每个路由的"目标"端点数量都是在每个路由中定义的,不同的路由可以有不同的目标端点数量。

请注意,在以下情况下:

from("direct:a").to("direct:x").to("direct:y");

你正在链接消息的处理。来自"direct:a"的结果将被发送到"direct:x",而来自"direct:x"的结果将被发送到"direct:y",因此"direct:y"可能会收到与"direct:x"不同的消息。

英文:

yes, you correctly understand that there is difference between network layer multicast and apache camel multicast.

The use case for camel multicast is when you want to send same message to the multiple endpoints. So in example from docs:

from("direct:a").multicast().to("direct:x", "direct:y", "direct:z");

The same message from "direct:a" will be send to all three endpoints. And the number of "destination" endpoints is defined for each route and could be different for different routes.

Note that in case of:

from("direct:a").to("direct:x").to("direct:y")

You are chaining processing of the messages. The result from the "direct:a" will be send to "direct:x" and the result from "direct:x" will be send to "direct:y", so "direct:y" could get different message as "direct:x".

huangapple
  • 本文由 发表于 2020年10月8日 15:23:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/64257638.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定