ActiveMQ Artemis 集群:JMS ConnectionFactory
ActiveMQ Artemis cluster: JMS ConnectionFactory
我想设置一个有 4 个节点的 ActiveMQ Artemis HA 集群:两个主节点,两个从节点。
我已经尝试过只使用一个节点,它正在运行。现在我必须在我的代码中调整 ConnectionFactory
以便它可以连接到集群。
在 ActiveMQ Artemis 文档中,我发现了类似的内容:
@Bean
public ConnectionFactory connectionFactory() {
TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName());
ConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, transportConfiguration);
return cf;
}
JavaDoc 说:
Creates an ActiveMQConnectionFactory that receives cluster topology updates from the cluster as servers leave or join and new backups are appointed or removed.
如何在此处设置指定的url用于ssl等用途?
@Bean
public ConnectionFactory connectionFactory() {
ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616?sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample");
return cf;
}
JMS 连接工厂,文档中未进一步指定。
此处是否下载了拓扑信息?
它的预期使用方式是什么?
客户端收到的拓扑信息只真正用于故障转移。要创建支持故障转移的 JMS 连接工厂 URL,只需添加值为 true
的 ha
参数,例如:
tcp://localhost:61616?ha=true
如果您需要 SSL/TLS 配置,您也可以添加它,例如:
tcp://localhost:61616?ha=true&sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample
如果您希望 URL 能够连接到集群中的任何节点,那么您可以添加多个 host/port 元素,例如:
(tcp://node1:61616,tcp://node2:61616,tcp://node3:61616,tcp://node4:61616)?ha=true&sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample
除了硬编码 host/port 元素,您还可以使用 UDP 发现来查找集群节点,例如:
udp://231.7.7.7:9876?ha=true&sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample
此处使用的组地址和端口(即 231.7.7.7:9876
)应与为集群节点配置的 broadcast-group
使用的组地址和端口相匹配。此外,请记住,此处使用的 UDP 数据包通常仅在单个子网中传输。
我想设置一个有 4 个节点的 ActiveMQ Artemis HA 集群:两个主节点,两个从节点。
我已经尝试过只使用一个节点,它正在运行。现在我必须在我的代码中调整 ConnectionFactory
以便它可以连接到集群。
在 ActiveMQ Artemis 文档中,我发现了类似的内容:
@Bean
public ConnectionFactory connectionFactory() {
TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName());
ConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, transportConfiguration);
return cf;
}
JavaDoc 说:
Creates an ActiveMQConnectionFactory that receives cluster topology updates from the cluster as servers leave or join and new backups are appointed or removed.
如何在此处设置指定的url用于ssl等用途?
@Bean
public ConnectionFactory connectionFactory() {
ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616?sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample");
return cf;
}
JMS 连接工厂,文档中未进一步指定。
此处是否下载了拓扑信息?
它的预期使用方式是什么?
客户端收到的拓扑信息只真正用于故障转移。要创建支持故障转移的 JMS 连接工厂 URL,只需添加值为 true
的 ha
参数,例如:
tcp://localhost:61616?ha=true
如果您需要 SSL/TLS 配置,您也可以添加它,例如:
tcp://localhost:61616?ha=true&sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample
如果您希望 URL 能够连接到集群中的任何节点,那么您可以添加多个 host/port 元素,例如:
(tcp://node1:61616,tcp://node2:61616,tcp://node3:61616,tcp://node4:61616)?ha=true&sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample
除了硬编码 host/port 元素,您还可以使用 UDP 发现来查找集群节点,例如:
udp://231.7.7.7:9876?ha=true&sslEnabled=true&trustStorePath=activemq.example.truststore&trustStorePassword=activemqexample
此处使用的组地址和端口(即 231.7.7.7:9876
)应与为集群节点配置的 broadcast-group
使用的组地址和端口相匹配。此外,请记住,此处使用的 UDP 数据包通常仅在单个子网中传输。