2

IBM MQ has an automatic client renonnect functionality, and it has a default timeout of 30 minutes. After 30 minutes it stops trying to reconnect (source - p35).

I want to change the timeout so it lasts a longer time retrying (for example 2 hours). I suppose I can use the property XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT for this because it's available in the XMSC class.

Testing

I can simulate a connection failure by blocking the port 1414 where the client application makes connection to IBM MQ. And for testing purposes, I lower the timeout value to 5 minutes (instead of 30 minutes).

What I can see in the logging is that the client application receives XMSException with reason code 2544 (reconnecting):

IBM.XMS.XMSException: MQ delivered an asynchronous event with completion code 1, and reason 2544.
XMSWMQ2014.explanation
XMSWMQ2014.useraction

Linked Exception : CompCode: 1, Reason: 2544

This occurs for 30 minutes, and after that, I get an XMSException with reason code 2009 (connection broken). And auto reconnect fails.

XMSException occurred: IBM.XMS.XMSException: MQ delivered an asynchronous event with completion code 2, and reason 2009.
XMSWMQ2014.explanation
XMSWMQ2014.useraction

Linked Exception : CompCode: 2, Reason: 2009

I can conclude that changing the timeout value has no effect... Am I configuring the reconnect timeout in a wrong way?

Below, there is a code snippet:

XMSFactoryFactory factory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
IConnectionFactory connectionFactory = factory.CreateConnectionFactory();
connectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, "hostname");
connectionFactory.SetIntProperty(XMSC.WMQ_PORT, 1414);
connectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, "channel_name");
connectionFactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT_UNMANAGED);
connectionFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "*");
connectionFactory.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_OPTIONS, XMSC.WMQ_CLIENT_RECONNECT_Q_MGR);
connectionFactory.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT, 300); //300 seconds = 5 minutes

IConnection conn = connectionFactory.CreateConnection();
conn.Start();

IBM MQ Client version: 8.0.0.5

Notes

JoshMc
  • 10,239
  • 2
  • 19
  • 38
Ozkan
  • 3,880
  • 9
  • 47
  • 78
  • 1
    Have you tried with anything later such as 8.0.0.11? – JoshMc Dec 28 '18 at 20:28
  • @JoshMc I even tried on v9.0.5.0, has no effect... – Ozkan Dec 31 '18 at 14:54
  • 1
    8.0.0.11 is newer than 9.0.5 which was the last 9.0 CD release. There is also 9.1.0.1 and 9.1.1 (this includes .net core support now). – JoshMc Dec 31 '18 at 15:03
  • Did you try Managed mode? – subbaraoc Jan 01 '19 at 06:19
  • @JoshMc Negative... I just tested with 8.0.0.11 but same behavior... Reconnect timeout is set to 5 minutes, but it tries to reconnect for 30 minutes (which is the default value...) – Ozkan Jan 02 '19 at 09:09
  • @subbaraoc managed mode is not an option for us. Some functionalities which are a requirement, such as SSL and compression, are only available in unmanaged mode. – Ozkan Jan 02 '19 at 09:12
  • Ozkan, have a PMR open with IBM about the .NET and MQ Reconnect Timeout, it has been open since last year but out of this they did open a APAR to fix some issues and one of the issues fixed I confirmed is that `XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT` does not work for unmanaged. Once this APAR is closed I'll post an answer to your question with the details. – JoshMc Jan 08 '19 at 05:16
  • 2
    Ozkan, after further review IBM responded that it is not currently possible for Unmanaged XMS.NET to support `XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT` because Unmanaged XMS.NET utilized the underlying MQ C API libraries and in those underlying libraries it is not possible to set the MQ Reconnect Timeout programmatically, even they must rely on the `mqclient.ini/CHANNELS:/MQReconnectTimeout` settings for this purpose. Because of this they will be updating the IBM MQ Knowledge center to state this limitation. – JoshMc Jan 23 '19 at 05:25

1 Answers1

2

I've found a way to accomplish this, but unfortunately not by code...

The reconnect timeout can be set in mqclient.ini.

Example:

CHANNELS:
MQReconnectTimeout = 14400

With this configuration applied, the client application should keep retrying for 4 hours.

Ozkan
  • 3,880
  • 9
  • 47
  • 78