MQ

 View Only

 IBM MQ: Can put messages, but fail to get them using Node.js client (permissions granted)

Song Bi's profile image
Song Bi posted Mon June 30, 2025 01:47 PM

I'm building a Node.js middleware server that connects to IBM MQ 9.4 running in a Docker container. I am using the official IBM MQ Node.js library (ibmmq) to send and receive messages.

I can successfully put messages into a queue, but getting (consuming) messages always hangs. I’ve verified that messages exist in the queue, and I’ve granted full permissions to the user.

function receiveFromMQ() {
  return new Promise((resolve, reject) => {
    const cno = new mq.MQCNO();
    cno.Options = MQC.MQCNO_CLIENT_BINDING;

    const cd = new mq.MQCD();
    cd.ConnectionName = "localhost(1414)";
    cd.ChannelName = "DEV.APP.SVRCONN";
    cno.ClientConn = cd;

    const csp = new mq.MQCSP();
    csp.UserId = "";
    csp.Password = "";
    cno.SecurityParms = csp;

    mq.Connx("QM1", cno, (connErr, hConn) => {
      if (connErr) return reject(connErr);

      const od = new mq.MQOD();
      od.ObjectName = "MY.DEV.QUEUE.1";
      od.ObjectType = MQC.MQOT_Q;

      mq.Open(hConn, od, MQC.MQOO_INPUT_SHARED, (openErr, hObj) => {
        if (openErr) return reject(openErr);

        const md = new mq.MQMD();
        const gmo = new mq.MQGMO();
        gmo.Options = MQC.MQGMO_NO_SYNCPOINT | MQC.MQGMO_WAIT;
        gmo.WaitInterval = 3000;

        mq.Get(hObj, md, gmo, (getErr, data) => {
          mq.Close(hObj, 0, () => mq.Disc(hConn));

          if (getErr) {
            if (getErr.mqrc === MQC.MQRC_NO_MSG_AVAILABLE) {
              resolve(null);
            } else {
              reject(getErr);
            }
          } else {
            resolve(data.toString());
          }
        });
      });
    });
  });
}

Observations:

  • mq.Put() works fine and adds visible messages.

  • mq.Get() hangs.

  • Tried MQOO_INPUT_AS_Q_DEF , MQOO_INPUT_SHARED and MQOO_BROWSE — no difference.

Screenshots:

❓Question:

What could cause put to succeed but get to fail in this setup, even with full permissions and verified message presence?

Any diagnostics or overlooked configuration I should double-check?

Thanks in advance!