The object handle passed to an MQ call is not valid, for example because it never came from MQOPEN, was already closed, or is used from the wrong thread.
QUICK ANSWER
The object handle passed to an MQ call is not valid, for example because it never came from MQOPEN, was already closed, or is used from the wrong thread.
LIKELY CAUSES, IN THE ORDER OF THIS ENTRY
The parameter pointer is not valid, or for MQOPEN it points to read-only storage.
The value was not returned by an earlier MQOPEN.
An earlier MQCLOSE made the handle invalid.
A shared handle was invalidated by another thread issuing MQCLOSE.
A nonshared handle is being used by a thread that did not create it.
On MQGET or MQPUT, the handle refers to an object that is not a queue.
IBM says the object handle (Hobj) is not valid. The call completes with MQCC_FAILED. The handle must come from a successful MQOPEN and still be in scope.
Typical causes
The parameter pointer is not valid, or for MQOPEN it points to read-only storage.
The value was not returned by an earlier MQOPEN.
An earlier MQCLOSE made the handle invalid.
A shared handle was invalidated by another thread issuing MQCLOSE.
A nonshared handle is being used by a thread that did not create it.
On MQGET or MQPUT, the handle refers to an object that is not a queue.
How to fix it
Make sure a successful MQOPEN was done for the object before the call.
Make sure MQCLOSE has not already been done for that handle.
Use the handle only within its valid scope (see the MQOPEN description for scope rules).