简体   繁体   English

ActiveMQ Artemis 集群:JMS ConnectionFactory

[英]ActiveMQ Artemis cluster: JMS ConnectionFactory

I want to setup an ActiveMQ Artemis HA cluster with 4 nodes: two masters, two slaves.我想设置一个有 4 个节点的 ActiveMQ Artemis HA 集群:两个主节点,两个从节点。

I already tried to to it with only one node, and it's working.我已经尝试过仅使用一个节点,并且它正在工作。 Now I have to adapt the ConnectionFactory in my code so that it can connect with the cluster.现在我必须在我的代码中调整ConnectionFactory以便它可以与集群连接。

In the ActiveMQ Artemis documentation I found something like that:在 ActiveMQ Artemis 文档中,我发现了类似的内容:

@Bean
public ConnectionFactory connectionFactory() {    
    TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName());
    ConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, transportConfiguration);
    return cf;
}

The JavaDoc says: JavaDoc说:

Creates an ActiveMQConnectionFactory that receives cluster topology updates from the cluster as servers leave or join and new backups are appointed or removed.创建一个 ActiveMQConnectionFactory,它在服务器离开或加入时从集群接收集群拓扑更新,并指定或删除新的备份。

How can I set a specified url here for ssl use and so on?如何在此处设置指定的 url 以供 ssl 使用等?

@Bean
public ConnectionFactory connectionFactory() {    
    ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616?sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample");
    return cf;
}

JMS connection factory, not further specified in documentation. JMS 连接工厂,文档中未进一步指定。

Are here topology infos downloaded?这里是否下载了拓扑信息?

What and how is the intended way of using it?预期的使用方式是什么以及如何使用它?

The topology information received by the client is only really used for failover.客户端收到的拓扑信息只是真正用于故障转移。 To create a JMS connection factory URL which supports failover simply add the ha parameter with the value true , eg:要创建支持故障转移的 JMS 连接工厂 URL,只需添加值为trueha参数,例如:

tcp://localhost:61616?ha=true

If you need SSL/TLS configuration you can add that as well, eg:如果您需要 SSL/TLS 配置,您也可以添加它,例如:

tcp://localhost:61616?ha=true&sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample

If you want the URL to be able to potentially connect to any node in the cluster than you can add multiple host/port elements, eg:如果您希望 URL 能够潜在地连接到集群中的任何节点,则可以添加多个主机/端口元素,例如:

(tcp://node1:61616,tcp://node2:61616,tcp://node3:61616,tcp://node4:61616)?ha=true&sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample

Instead of hard-coded host/port elements you can also use UDP discovery to find the cluster nodes, eg:除了硬编码的主机/端口元素,您还可以使用 UDP 发现来查找集群节点,例如:

udp://231.7.7.7:9876?ha=true&sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample

The group address and port used here (ie 231.7.7.7:9876 ) should match the group address and port used by the broadcast-group configured for your cluster nodes.此处使用的组地址和端口(即231.7.7.7:9876 )应与为集群节点配置的broadcast-group使用的组地址和端口匹配。 Also, keep in mind that the UDP packets used here are usually only transmitted across a single subnet.此外,请记住,此处使用的 UDP 数据包通常仅通过单个子网传输。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM