Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to IBM MQ Manager with HA configuration?

Tags:

c#

ibm-mq

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?

like image 658
PushCode Avatar asked Feb 07 '17 13:02

PushCode


1 Answers

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.

like image 135
T.Rob Avatar answered Oct 11 '22 09:10

T.Rob