我正在编写一个使用amqmdnet.dll连接到IBM Websphere MQ Manager的C#客户端,使用以下结构:
_myQueueManager = new MQQueueManager(queueManagerName, properties);
在属性哈希表中,我正在设置主机名、通道和队列管理器。现在,如何在我的客户端应用程序中实现自动重新连接功能?我们有IBM MQ多实例队列管理器HA配置。
基本上,如果我的客户端连接失败,我必须回退到四个终端点。
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.
一定要遵循在.NET中自动重新连接客户端中的建议,以确保选项在托管/非托管模式方面正确指定。