1

We are using IBM MQ as a messaging layer with multi instance setup. The .NET application using XMS client (ver 7.5) will read off messages from the multiple Queues. Since the volume of the message is high, I have created around 5 connection per queue to read the messages. And there are 4 such queues. So in the application at any point of time, there are 20 connections and 20 session opened. With this setup I am facing two issues:

  • Often I get the two XMS exceptions while opening the connections.One is MQRC_HOST_NOT_AVAILABLE ((2538, X’9EA’) The attempt to allocate a conversation to the remote system failed.) and the other is MQRC_CONNECTION_BROKEN(Connection to queue manager lost.)

  • While closing the application, it is taking lot more time to close of all the sessions and connections because they are too many of them.

So I was thinking to reduce the number of connection. By just creating one connection per queue and open 5 session per queue. In this way, the number of connections will be reduced to 4 (from 20). So both the above said issues will be solved I think (yet to try)

So wanted someone in the know, to share their experience on what is the best practice of handing the above scenario. Will there be any delay in delivering the messages if we open multiple sessions per connection compared to single session per connection?

The code I'm using is below:

private XMSFactoryFactory xMSFactoryFactory;
private IConnectionFactory connectionFactory;
private IConnection connectionWMQ;
private ISession sessionWMQ;
private IDestination destination;
private IMessageConsumer messageConsumer;

xMSFactoryFactory= XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
connectionFactory = _xMSFactoryFactory.CreateConnectionFactory();
// Set queue manager name, set server names, channel, use
// XMSC.WMQ_CM_CLIENT as WMQ_CONNECTION_MODE

connectionWMQ = _connectionFactory.CreateConnection();
sessionWMQ = _connectionWMQ.CreateSession(true, AcknowledgeMode.SessionTransacted);
destination = sessionWMQ.CreateQueue(_queueSettings.QueueName);
messageConsumer = sessionWMQ.CreateConsumer(_destination);
messageConsumer.MessageListener = new MessageListener(ProcessNewMessage)
JoshMc
  • 10,239
  • 2
  • 19
  • 38
Ranganatha
  • 1,157
  • 14
  • 32
  • You've accepted Shashi's answer so does that mean you've solved the problem? If so, could you leave a comment or update your question to indicate what the solution was for the benefit of future Stack Overflow users whose search turns up this Q&A? Thanks! – T.Rob Jul 24 '15 at 13:18

2 Answers2

2

The QMgr when properly tuned can handle many thousands of connections. The MQRC_HOST_NOT_AVAILABLE suggests that you are bumping against a resource limitation and MQRC_CONNECTION_BROKEN errors suggest that your sessions are not ending cleanly and are being orphaned.

Unfortunately, there is insufficient information to diagnose this with the question as written. If I were trying to diagnose, I'd want to know the configuration settings for all the relevant tuning parameters:

  • MAXHANDS
  • SHARECONV
  • The max channel instance settings at the QMgr and channel
  • Listener backlog settings
  • MAXUMSGS
  • Keepalive, heartbeat and other channel tuning

Operationally, I'd want to know how many channel instances were running when this happens.

I'd also want to know what errors are seen, if any, in the global error log and the QMgr's error log.

I'd query for uncommitted transactions and look for rollback events in the error log. With a default tuned QMgr transaction rollbacks can cause channel loss if the exceptions aren't handled, and this is not something people intuitively look for.

The answers to these might lead to tuning the QMgr, enhancing the app, or more diagnostics, after which I'd try again.

But the question hasn't included even basic diagnostic information at this point so it is impossible to determine root cause with any confidence whatsoever. What I can say based on the question as written is that the one thing I wouldn't do is to try to resolve this by reducing the number of connections in the app since the 20 legitimate the app is designed for is trivial for any QMgr.

T.Rob
  • 31,522
  • 9
  • 59
  • 103
1

Not much of action happens on Connection. It's used for creating temporary destinations. Session is where all the actions happens. So just one connection is sufficient.

MQRC_HOST_NOT_AVAILABLE and MQRC_CONNECTION_BROKEN may not be due to the number of connections/sessions you are creating because a queue manager can support a large number connections.

Your application is using a transacted session and message listener. How are you committing transaction. Can you show us the code for that? Are you calling commit for every message received?

Shashi
  • 14,980
  • 2
  • 33
  • 52
  • Yes, Shashi. I'm committing on each message. If not how can we commit the session? if (_queueSettings.UseTransactedSession && _disposed != true) { _sessionWMQ.Commit(); } – Ranganatha Jul 20 '15 at 14:52