在 Artemis 集群中的 brokerURL。

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

brokerURL in an Artemis cluster

问题

我有一个Artemis经纪人集群,包括两个主经纪人和两个从经纪人。我正试图以编程方式向此集群推送消息。我理解,对于只有一个经纪人的情况,应将brokerUrl设置为ActiveMQConnectionFactory.setBrokerUrl(String brokerURL)中的tcp://10.10.100.217:61616。

现在,我有一个包含两个主经纪人和两个从经纪人的集群,那么在这种情况下,brokerURL应该是什么?broker.xml中的group-address为231.7.7.7。

英文:

I have an Artemis brokers cluster with two master and two slave brokers. I am trying to push messages to this cluster programmatically. I understand with only one broker the brokerUrl to set in ActiveMQConnectionFactory.setBrokerUrl(String brokerURL) would be
tcp://10.10.100.217:61616.

Now, I have a cluster with two master and two slave brokers so in that case what would be the brokerURL? The group-address in broker.xml is 231.7.7.7.

答案1

得分: 1

有几种方法可以处理这个问题。

首先,你可以直接将所有的主机和端口添加到URL中,例如:

(tcp://master1:61616,tcp://slave1:61616,tcp://master2:61616,tcp://slave2:61616)

当核心客户端连接到主节点时,它将自动被通知任何备份情况,但不能保证预定义的主节点中一定会有一个处于活动状态,因此最安全的做法是在URL中列出所有的代理。

其次,你可以从客户端使用发现功能,例如:

udp://231.7.7.7:9876

在这里,客户端使用与代理形成集群的相同UDP多播地址和端口。客户端将在此多播地址和端口上监听,以发现哪些代理处于活动状态,然后连接到其中之一。

当然,为了使这个方法有效,UDP多播数据包必须能够从代理传输到客户端,这通常意味着它们必须在相同的网络子网上,因为UDP多播通常不会广播到子网之外。

英文:

There's a couple of ways you can deal with this.

First, you can just add all the hosts and ports to the URL, e.g.:

(tcp://master1:61616,tcp://slave1:61616,tcp://master2:61616,tcp://slave2:61616)

When a core client connects to a master it will automatically be informed of any backup, but you can't guarantee that one of the predefined masters will actually be up so it's safest to just list all the brokers in the URL.

Second, you can use discovery from the client, e.g.:

udp://231.7.7.7:9876

Here the client uses the same UDP multicast address and port that the brokers use to form the cluster. The client will listen on this multicast address & port to discover which brokers are up and then connect to one of them.

Of course for this to work UDP multicast packets must be able to reach the client from the broker and that typically means they have to be on the same network subnet as UDP multicast is typically not broadcast beyond this.

huangapple
  • 本文由 发表于 2020年10月20日 04:25:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/64434678.html
匿名

发表评论

匿名网友

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

确定