How to use the ibmmq.MQMD function in ibmmq

To help you get started, we’ve selected a few ibmmq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ibm-messaging / mq-mqi-nodejs / tests / amqsgetar.js View on Github external
function getMessage() {
  var md = new mq.MQMD();
  var gmo = new mq.MQGMO();

  gmo.Options = MQC.MQGMO_NO_SYNCPOINT |
    MQC.MQGMO_WAIT |
    MQC.MQGMO_CONVERT |
    MQC.MQGMO_FAIL_IF_QUIESCING;
  gmo.MatchOptions = MQC.MQMO_NONE;
  gmo.WaitInterval = waitInterval * 1000; // 3 seconds

  if (msgId != null) {
    console.log("Setting Match Option for MsgId");
    gmo.MatchOptions = MQC.MQMO_MATCH_MSG_ID;
    md.MsgId = hexToBytes(msgId);
  }

  // Set up the callback handler to be invoked when there
github ibm-messaging / mq-mqi-nodejs / samples / amqsdlh.js View on Github external
function getMessage(hObj) {

  var buf = Buffer.alloc(1024);

  var mqmd = new mq.MQMD();
  var gmo = new mq.MQGMO();

  gmo.Options = MQC.MQGMO_NO_SYNCPOINT |
                MQC.MQGMO_NO_WAIT |
                MQC.MQGMO_CONVERT |
                MQC.MQGMO_FAIL_IF_QUIESCING;

  try {
    var len = mq.GetSync(hObj,mqmd,gmo,buf);
    var format = mqmd.Format;

    // If the message has a DLH then
    // parse and print it.
    if (format == MQC.MQFMT_DEAD_LETTER_HEADER) {
      var hdr = mq.MQDLH.getHeader(buf);
      console.log("HDR is %j",hdr);
github ibm-messaging / mq-dev-patterns / Node.js / basicpublish.js View on Github external
function publishMessage(hObj) {

  var msgObject = {
    'Greeting': "Hello from Node at " + new Date()
  }
  var msg = JSON.stringify(msgObject);

  var mqmd = new mq.MQMD(); // Defaults are fine.
  var pmo = new mq.MQPMO();

  // Describe how the Publish (Put) should behave
  pmo.Options = MQC.MQPMO_NO_SYNCPOINT |
    MQC.MQPMO_NEW_MSG_ID |
    MQC.MQPMO_NEW_CORREL_ID;
  // Add in the flag that gives a warning if noone is
  // subscribed to this topic.
  pmo.Options |= MQC.MQPMO_WARN_IF_NO_SUBS_MATCHED;
  mq.Put(hObj, mqmd, pmo, msg, function(err) {
    if (err && 'object' === typeof err && err.mqrc &&
      MQC.MQRC_NO_SUBS_MATCHED == err.mqrc && err.mqrcstr) {
      debug_info('Publish unsuccessful because there are no subscribers', err.mqrcstr);
    } else if (err) {
      debug_warn('Error Detected in Put operation', err);
    } else {
github ibm-messaging / mq-dev-patterns / Node.js / basicrequest.js View on Github external
function getResponse(hObjDynamic, msgId, cb) {
  debug_info("Waiting for response to request for msgId ", msgId);
  var buf = Buffer.alloc(1024);

  var mqmd = new mq.MQMD();
  var gmo = new mq.MQGMO();

  gmo.Options = MQC.MQGMO_NO_SYNCPOINT |
    MQC.MQGMO_NO_WAIT |
    MQC.MQGMO_CONVERT |
    MQC.MQGMO_FAIL_IF_QUIESCING;

  gmo.MatchOptions = MQC.MQMO_MATCH_MSG_ID;
  mqmd.MsgId = hexToBytes(msgId);

  // gmo.MatchOptions = MQC.MQMO_MATCH_CORREL_ID
  // mqmd.CorrelId = hexToBytes(msgId);

  mq.GetSync(hObjDynamic, mqmd, gmo, buf, function(err, len) {
    if (err) {
      if (err.mqrc == MQC.MQRC_NO_MSG_AVAILABLE) {
github ibm-messaging / mq-dev-patterns / Node.js / basicrequest.js View on Github external
function putMessage(hObj, hObjDynamic, cb) {

  // var msg = "Hello from Node at " + new Date();
  var msgObject = {
    'Greeting': "Hello from Node at " + new Date(),
    'value': Math.floor(Math.random() * 100)
  }
  var msg = JSON.stringify(msgObject);

  var mqmd = new mq.MQMD(); // Defaults are fine.
  mqmd.ReplyToQ = hObjDynamic._name;
  mqmd.MsgType = MQC.MQMT_REQUEST;

  var pmo = new mq.MQPMO();

  // Describe how the Put should behave
  pmo.Options = MQC.MQPMO_NO_SYNCPOINT |
    MQC.MQPMO_NEW_MSG_ID |
    MQC.MQPMO_NEW_CORREL_ID;

  mq.Put(hObj, mqmd, pmo, msg, function(err) {
    if (err) {
      debug_warn('Error Detected in Put operation', err);
      cb(err, null);
    } else {
      var msgId = toHexString(mqmd.MsgId);
github ibm-messaging / mq-mqi-nodejs / samples / amqsget.js View on Github external
function getMessage(hObj) {

  var buf = Buffer.alloc(1024);
  var hdr;
  var mqmd = new mq.MQMD();
  var gmo = new mq.MQGMO();

  gmo.Options = MQC.MQGMO_NO_SYNCPOINT |
                MQC.MQGMO_NO_WAIT |
                MQC.MQGMO_CONVERT |
                MQC.MQGMO_FAIL_IF_QUIESCING;


  mq.GetSync(hObj,mqmd,gmo,buf,function(err,len) {
    if (err) {
       if (err.mqrc == MQC.MQRC_NO_MSG_AVAILABLE) {
         console.log("no more messages");
       } else {
         console.log(formatErr(err));
       }
       ok = false;
github ibm-messaging / mq-dev-patterns / Node.js / basicget.js View on Github external
return new Promise(function resolver(resolve, reject) {
    let buf = Buffer.alloc(1024);

    let mqmd = new mq.MQMD();
    let gmo = new mq.MQGMO();

    gmo.Options = MQC.MQGMO_NO_SYNCPOINT |
      MQC.MQGMO_NO_WAIT |
      MQC.MQGMO_CONVERT |
      MQC.MQGMO_FAIL_IF_QUIESCING;

      mq.GetSync(hObj, mqmd, gmo, buf, function(err, len) {
        if (err) {
          if (err.mqrc == MQC.MQRC_NO_MSG_AVAILABLE) {
            debug_info("no more messages");
          } else {
            debug_warn('Error retrieving message', err);
          }
          debug_info('Returning false from getMessage');
          resolve(false);
github ibm-messaging / mq-dev-patterns / Node.js / basicresponse.js View on Github external
function getMessage(hConn, hObj) {
  var buf = Buffer.alloc(1024, 0);

  var mqmd = new mq.MQMD();
  var gmo = new mq.MQGMO();

  gmo.Options = MQC.MQGMO_NO_SYNCPOINT |
    MQC.MQGMO_NO_WAIT |
    MQC.MQGMO_CONVERT |
    MQC.MQGMO_FAIL_IF_QUIESCING;

  mq.GetSync(hObj, mqmd, gmo, buf, function(err, len) {
    if (err) {
      if (err.mqrc == MQC.MQRC_NO_MSG_AVAILABLE) {
        debug_info("no more messages");
      } else {
        debug_warn('Error retrieving message', err);
      }
      ok = false;
    } else if (mqmd.Format == "MQSTR") {