如何检查MQ是否连接
How to check if MQ is connected
我正在尝试连接到我的 MQ 服务器。我有 2 个 MQ 服务器:服务器 1 和服务器 2,并将其设置为 connectionNameList
for mqConnectionFactory
。如果服务器 2 出现故障,MQ 是否可以连接到服务器 1?我如何知道 MQ 服务器是否已连接?我看到 clientReconnectOptions
设置为 67108864
但我不确定那是什么。
ClientReconnectOptions 的可能设置记录在 IBM MQ 知识中心页面 CLIENTRECONNECTOPTIONS
下面是一个使用 setClientReconnectOptions
进行设置的示例,因此应用程序可以重新连接到在 connectionNameList
.
中设置的两个主机(端口)组合上列出的任何队列管理器
MQQueueConnectionFactory factory = new MQQueueConnectionFactory();
factory.setQueueManager("QMNAME");
factory.setChannel("SVRCONN.CHL");
factory.setConnectionNameList("hostName1(port),hostName2(port)");
factory.setClientReconnectOptions( WMQConstants.WMQ_CLIENT_RECONNECT );
// Set the amount of time you will attempt to reconnect in seconds
factory.setClientReconnectTimeout( 43200 ); //12 hours
//default is 1800 seconds
//factory.setClientReconnectTimeout(WMQConstants.WMQ_CLIENT_RECONNECT_TIMEOUT_DEFAULT);
请注意,客户端不会总是尝试重新连接,请参阅 Linux 上的 endmqm
手册页中的以下内容:
If you issue endmqm to stop a queue manager, reconnectable clients do
not try to reconnect. To override this behavior, specify either the -r
or -s option to enable clients to start trying to reconnect.
Note: If a queue manager or a channel ends unexpectedly, reconnectable
clients start trying to reconnect.
我正在尝试连接到我的 MQ 服务器。我有 2 个 MQ 服务器:服务器 1 和服务器 2,并将其设置为 connectionNameList
for mqConnectionFactory
。如果服务器 2 出现故障,MQ 是否可以连接到服务器 1?我如何知道 MQ 服务器是否已连接?我看到 clientReconnectOptions
设置为 67108864
但我不确定那是什么。
ClientReconnectOptions 的可能设置记录在 IBM MQ 知识中心页面 CLIENTRECONNECTOPTIONS
下面是一个使用 setClientReconnectOptions
进行设置的示例,因此应用程序可以重新连接到在 connectionNameList
.
MQQueueConnectionFactory factory = new MQQueueConnectionFactory();
factory.setQueueManager("QMNAME");
factory.setChannel("SVRCONN.CHL");
factory.setConnectionNameList("hostName1(port),hostName2(port)");
factory.setClientReconnectOptions( WMQConstants.WMQ_CLIENT_RECONNECT );
// Set the amount of time you will attempt to reconnect in seconds
factory.setClientReconnectTimeout( 43200 ); //12 hours
//default is 1800 seconds
//factory.setClientReconnectTimeout(WMQConstants.WMQ_CLIENT_RECONNECT_TIMEOUT_DEFAULT);
请注意,客户端不会总是尝试重新连接,请参阅 Linux 上的 endmqm
手册页中的以下内容:
If you issue endmqm to stop a queue manager, reconnectable clients do not try to reconnect. To override this behavior, specify either the -r or -s option to enable clients to start trying to reconnect.
Note: If a queue manager or a channel ends unexpectedly, reconnectable clients start trying to reconnect.