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.

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.