IBM MQ reason code

MQRC 2039: Handle not open for output

MQRC 2039 means MQPUT used a queue handle without output capability. Check the MQOPEN options and whether code reused a consumer or browse handle.

Other names for this code

Also written as RC2039, reason code 2039, MQ error 2039, MQRC_NOT_OPEN_FOR_OUTPUT, 07F7, 0x07F7.

What it means

MQPUT needs a handle opened with MQOO_OUTPUT. Having a valid connection and a valid queue handle is not sufficient when the handle was opened only for input, browse or inquiry.

The error identifies an API usage mismatch. It does not by itself establish that the queue is disabled for puts; MQRC 2051 reports that different condition.

A troubleshooting example

A worker gets a request from REQUEST.IN and sends its reply using the same handle variable. The reply fails with 2039 because that handle was opened for input. The correct change is to resolve the actual reply queue from the message contract, open that queue for output and put through the new handle. Test with distinct input and reply queues so a variable mix-up cannot accidentally appear to work. Inspect the destination of the resulting message, not only the absence of an exception.

Common causes

  • A request processor reuses its input handle to send a reply.
  • A handle cache indexes only by queue name and ignores open capabilities.
  • A refactor replaces an output open with an inquiry or browse open while retaining the same variable.

How to find the problem

  1. Capture the exact Hobj passed to MQPUT and trace its creation. Check for variable reassignment and cached-handle reuse.
  2. Inspect the open-options mask at runtime, not only a configuration file. Conditional initialization may select a different mode.
  3. For replies, compare the reply destination with the input queue and verify that the program obtains an output handle for that destination.
  4. Check the earlier completion code from MQOPEN. Do not continue using a handle after an unsuccessful open.

How to fix it

  • Open the destination with MQOO_OUTPUT and use that handle for puts. Keep its ownership and cleanup separate from the input handle.
  • If using a handle cache, include required capabilities in the cache design. A queue-name match alone cannot guarantee a usable producer handle.
  • Test successful replies and failed-open paths. Verify that every put uses the intended destination and that a failed open prevents subsequent message calls.

What it looks like

Illustrative diagnostic notes; not an IBM message template.
MQOPEN REQUEST.IN: MQOO_INPUT_SHARED
MQPUT using input Hobj: Reason=2039
Open the intended destination with MQOO_OUTPUT.

IBM documentation

IBM MQ 9.4: 2039 MQRC_NOT_OPEN_FOR_OUTPUT. Use the documentation for your installed release.

Report a correction to WND Software.

Questions

Is this the same as PUT(DISABLED)?

No. 2039 identifies a handle without output capability. 2051 identifies puts inhibited on the queue or resolved destination.

Does reconnecting add output capability?

No. The required capability comes from the object open. Correct the open and the handle passed to MQPUT.