IBM MQ change userID when an app is started on remote MQ

11/20/2019

When I deploy my app to remote IBM MQ. Then I see that userID is changed to a user of my pc. I set userID = prod, but see in logs (get logs from a remote MQ), that userID = ps (ps - the user of my pc). But, if the app is started locally, I don't see this problem.

I use ubuntu, docker, Kubernetes, node.js. I put userID in code, but might I should config it through Docker? Or how should the conf be changed to fix this problem?

("use strict");
const mq = require("ibmmq");
const fs = require("fs");
const logger = require("../config/logerConfig");
const MQC = mq.MQC;

const StringDecoder = require("string_decoder").StringDecoder;
const decoder = new StringDecoder("utf8");

function ToMQ() {
  const qMgr = "queueManagerName";
  const qName = "queueName";
  const connName = "somehost";

  let queueHandle;

  const cno = new mq.MQCNO();
  const sco = new mq.MQSCO();
  const csp = new mq.MQCSP();
  const cd = new mq.MQCD();
  csp.UserId = "prod";
  csp.Password = "";
  cno.SecurityParms = csp;
  cno.Options |= MQC.MQCNO_CLIENT_BINDING;
  cd.ConnectionName = connName;
  cd.ChannelName = "channelName";
  //cd.SSLCipherSpec = "TLS_RSA_WITH_AES_128_CBC_SHA256";
  cd.SSLClientAuth = MQC.MQSCA_OPTIONAL;
  cno.ClientConn = cd;
  cno.SSLConfig = sco;

  mq.setTuningParameters({
    syncMQICompat: true
  });

  mq.Connx(qMgr, cno, function(err, hConn) {
    if (err) {
      logger.errorLogger().error("Failed to connect to MQ!");
    } else {
      logger.serverLogger().info(`Connection successful`);

      const od = new mq.MQOD();
      od.ObjectName = qName;
      od.ObjectType = MQC.MQOT_Q;
      const openOptions = MQC.MQOO_BROWSE;
      mq.Open(hConn, od, openOptions, function(err, hObj) {
        queueHandle = hObj;
        if (err) {
          logger.errorLogger().error(err.message);
        } else {
          getMessages();
        }
      });
    }
  });
}

function formatErr(err) {
  if (err) {
    ok = false;
    return "MQ call failed at " + err.message;
  } else {
    return "MQ call successful";
  }
}

function getMessages() {
  const md = new mq.MQMD();
  const gmo = new mq.MQGMO();

  gmo.Options =
    MQC.MQGMO_NO_SYNCPOINT |
    MQC.MQGMO_MQWI_UNLIMITED |
    MQC.MQGMO_CONVERT |
    MQC.MQGMO_FAIL_IF_QUIESCING;
  gmo.Options |= MQC.MQGMO_BROWSE_FIRST;

  gmo.MatchOptions = MQC.MQMO_NONE;

  mq.setTuningParameters({
    getLoopPollTimeMs: 500
  });
  mq.Get(queueHandle, md, gmo, getCB);
}

function getCB(err, hObj, gmo, md, buf, hConn) {
  if (err) {
    if (err.mqrc == MQC.MQRC_NO_MSG_AVAILABLE) {
      logger.serverLogger().info("No more messages available.");
    } else {
      logger.errorLogger().error(formatErr(err.message));
      exitCode = 1;
    }
    ok = false;
    mq.GetDone(hObj);
  } else {
    if (md.Format == "MQSTR") {
      const message = decoder.write(buf);
      const metaJSON = getMetaJson(message);
      try {
        fs.writeFileSync(
          .... process
        );
        logger.serverLogger().info(message);
      } catch (e) {
        logger.errorLogger().error("Cannot write file ", e.message);
      }
    } else {
      logger.serverLogger().info("binary message: " + buf);
    }
    gmo.Options &= ~MQC.MQGMO_BROWSE_FIRST;
    gmo.Options |= MQC.MQGMO_BROWSE_NEXT;
  }
}

function getMetaJson(message) {
 // parse JSON
}
-- Pavlo NN
ibm-mq
javascript
kubernetes
node.js
websphere

0 Answers