One of our MQ client applications uses the .NET XMS package to connect to a queue as a consumer (9.2.2 version of
IBMMQDotnetClient). We're investigating an issue where it appears the message handler is not responding even though there are messages waiting on the queue. We are early in the debugging process, though. The issue is intermittent, which makes it more challenging. I don't have any experience with this client so I'm reaching out to the larger audience to make sure we're using it correctly.
The goal is for the client to detect network issues and automatically attempt to reconnect -- either by allowing XMS to monitor and drive this, or with monitoring code we write in the client. This is how the connection code is written:
XMSFactoryFactory factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
// Create WMQ Connection Factory.
IConnectionFactory connectionFactory = factoryFactory.CreateConnectionFactory();
//Set the properties
connectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, servicesInfo.HostName);
connectionFactory.SetStringProperty(XMSC.WMQ_PORT, servicesInfo.Port);
connectionFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, servicesInfo.QueueManagerName);
connectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, servicesInfo.ChannelName);
connectionFactory.SetStringProperty(XMSC.USERID, Globals.mqUserId);
connectionFactory.SetStringProperty(XMSC.PASSWORD, Globals.mqPwd);
connectionFactory.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_OPTIONS, XMSC.WMQ_CLIENT_RECONNECT);
connectionFactory.SetStringProperty(XMSC.WMQ_APPLICATIONNAME, ServiceName + "-" + domainName);
connectionFactory.SetStringProperty(XMSC.WMQ_CONNECTION_NAME_LIST, servicesInfo.HostName + "(" + servicesInfo.Port + ")");
// Create the connection and register an exception listener
connection = connectionFactory.CreateConnection();
connection.ExceptionListener = new ExceptionListener(OnException);
session = connection.CreateSession(true, AcknowledgeMode.SessionTransacted);
if (session == null)
{
LogFile.WriteToLog("Error in creating connection to WMQ_PROVIDER");
}
//Create Destination
destination = session.CreateQueue(servicesInfo.QueueName);
//Create Consumer
consumer = session.CreateConsumer(destination);
// Setup a message listener and assign it to consumer
messageListener = new MessageListener(OnMessageReceive);
consumer.MessageListener = messageListener;
// Start the connection to receive messages.
connection.Start();
and this is the receive handler
protected void OnMessageReceive(IMessage message)
{
ITextMessage Msg = (ITextMessage)message;
// Log message handler invoked.
try
{
// Process the message
}
catch (Exception ex)
{
// Log an exception
}
finally
{
// Handle finally block
}
}
What is the best solution to monitor MQ connectivity with this client and make sure it remains active (or that we report an error in the event we are unable to restore a connection)?
Thanks
------------------------------
Jim Creasman
------------------------------