5
votes

I am writing a C# client that connects to IBM Websphere MQ Manager using amqmdnet.dll using the following construct:

_myQueueManager = new MQQueueManager(queueManagerName, properties);

In the properties Hashtable I am setting hostname, channel and queuemanager. Now, how can I have auto reconnect functionality in my client application? We have IBM MQ multi-instance queue manager HA configuration.

Basically, I have four end points to which I have to fall back in case of connection failure from my client?

1

1 Answers

6
votes

According to 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.

Be sure to also follow the advice in Automatic client reconnection in .NET to make sure the option is correctly specified with respect to managed/unmanaged mode.