IBM MQ: CWSMQ0082E: Failed to send to CompCode: 2, Reason: 2017

3.4k views Asked by At

I am trying to send Text messages using IBM XMS for .NET. After sending around 254 messages, I get following error:

An unhandled exception of type 'IBM.XMS.XMSException' occurred in IBM.XMS.Client.WMQ.dll

Additional information: CWSMQ0082E: Failed to send to CompCode: 2, Reason: 2017.

There isn't much on google about it. I found one related post at WSMQ Queue Limit

The post suggest that there is some sort of limit in max queues. The links in the post don't seem to work. How do I overcome this error ?

1

There are 1 answers

0
T.Rob On BEST ANSWER

MQ has a command mqrc which returns the text for any reason code or message code. The 2017 means MQRC_HANDLE_NOT_AVAILABLE. A better explanation can be had by going to the Knowledge Center and searching on 2017. This returns several pages of API calls which can return 2017, along with the page for the reason code itself:

2017 (07E1) (RC2017): MQRC_HANDLE_NOT_AVAILABLE.

That page provides the following description of the problem:

Explanation
An MQOPEN, MQPUT1 or MQSUB call was issued, but the maximum number of open handles allowed for the current task has already been reached. Be aware that when a distribution list is specified on the MQOPEN or MQPUT1 call, each queue in the distribution list uses one handle.

We know from the documentation, and can confirm from MQ Explorer's QMgr Extended Properties panel, that by default the maximum handles any process will be allowed to have is 256.

Screen shot of MQ Explorer QMgr Extended Properties panel

Based on all this and that your program is dying after 254 messages, the conclusion is that it is grabbing a fresh handle for every message being PUT and not ever releasing them.

Generally this occurs when there is a loop that should contain only the PUT and COMMIT but instead also contains the OPEN. I would suggest carefully reviewing your code, possibly also updating your question to post the code here.

I would also suggest studying the MQ .Net sample programs or using one of them as the basis for your own code.