What it means
Every MQI call after MQCONN needs the connection handle that MQCONN returned. 2018 means the value passed is not a live handle for this thread or process. This is almost always a program logic or build problem, not a queue manager problem.
Typical causes
- MQCONN or MQCONNX was not called, or it failed and the program carried on anyway.
- The program already called MQDISC and then used the old handle.
- A handle was shared between threads or processes in a way MQ does not allow.
- On z/OS, the program was link-edited with the wrong MQ stub for its environment, or a stub from a newer MQ release.
- On CICS, a data conversion exit that calls MQXCNVC is not defined as OPENAPI.
How to fix it
- Check that MQCONN or MQCONNX completed successfully before any other call, and that the program stops if it did not.
- Make sure the handle is not used after MQDISC and is only used on the thread that is allowed to use it.
- On z/OS, link batch programs with CSQBSTUB, CICS programs with CSQCSTUB and IMS programs with CSQQSTUB, at a level no newer than the queue manager.
- On CICS, define any conversion exit that calls MQXCNVC as OPENAPI.
Example
Illustrative only; names and values are invented.
MQPUT failed CompCode=2 Reason=2018 Hconn=0