如何使用 HA 配置连接到 IBM MQ Manager?

How to connect to IBM MQ Manager with HA configuration?

我正在编写一个 C# 客户端,它使用 amqmdnet.dll 使用以下结构连接到 IBM Websphere MQ Manager:

_myQueueManager = new MQQueueManager(queueManagerName, properties);

在 Hashtable 属性中,我正在设置主机名、通道和队列管理器。现在,我怎样才能在我的客户端应用程序中拥有自动重新连接功能?我们有 IBM MQ 多实例队列管理器 HA 配置。

基本上,我有四个端点,如果我的客户端连接失败,我必须回退到这些端点?

根据the docs

You can supply a list of hostnames and ports as an argument to the constructor MQQueueManager (String queueManagerName, Hashtable properties) using CONNECTION_NAME_PROPERTY.

For example:

ConnectionName = "fred.mq.com(2344),nick.mq.com(3746),tom.mq.com(4288)";
Hashtable Properties-new Hashtable();
properties.Add(MQC.CONNECTION_NAME_PROPERTY,ConnectionName);
MQQueueManager qmgr=new MQQueue Manager("qmgrname",properties);

When a connection attempt is made, the connection name list is processed in order. If the connection attempt to the first host name and port fails, then connection to the second pair of attributes is attempted. The client repeats this process until either a successful connection is made or the list is exhausted. If the list is exhausted, an appropriate reason code and completion code is returned to the client application.

一定要遵循 Automatic client reconnection in .NET 中的建议,以确保针对 managed/unmanaged 模式正确指定选项。