How to use the ibmmq.Open 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 / samples / amqsinq.js View on Github external
mq.Connx(qMgr, cno, function(err,hConn) {
   if (err) {
     console.log(formatErr(err));
   } else {
     console.log("MQCONN to %s successful ", qMgr);

     // Define what we want to open, and how we want to open it.
     // In this case, we want to INQUIRE on attributes of the queue manager so we
     // get an object handle that refers to that qmgr.
     // No ObjectName is needed for this inquiry - the fact that it is the Q_MGR type
     // is sufficient.
     var od = new mq.MQOD();
     od.ObjectName = null;
     od.ObjectType = MQC.MQOT_Q_MGR;
     var openOptions = MQC.MQOO_INQUIRE;
     mq.Open(hConn,od,openOptions,function(err,hObj) {
       if (err) {
         console.log(formatErr(err));
       } else {
         console.log("MQOPEN of queue manager successful");
         inqQmgr(hObj);
       }
       cleanup(hConn,hObj);
     });
   }
});
github ibm-messaging / mq-mqi-nodejs / samples / amqsput.js View on Github external
mq.Connx(qMgr, cno, function(err,hConn) {
   if (err) {
     console.log(formatErr(err));
   } else {
     console.log("MQCONN to %s successful ", qMgr);

     // Define what we want to open, and how we want to open it.
     var od = new mq.MQOD();
     od.ObjectName = qName;
     od.ObjectType = MQC.MQOT_Q;
     var openOptions = MQC.MQOO_OUTPUT;
     mq.Open(hConn,od,openOptions,function(err,hObj) {
       if (err) {
         console.log(formatErr(err));
       } else {
         console.log("MQOPEN of %s successful",qName);
         putMessage(hObj);
       }
       cleanup(hConn,hObj);
     });
   }
});
github ibm-messaging / mq-mqi-nodejs / samples / amqsgeta.js View on Github external
mq.Conn(qMgr, function(err,hConn) {
   if (err) {
     console.log(formatErr(err));
     ok = false;
   } else {
     console.log("MQCONN to %s successful ", qMgr);
     connectionHandle = hConn;

     // Define what we want to open, and how we want to open it.
     var od = new mq.MQOD();
     od.ObjectName = qName;
     od.ObjectType = MQC.MQOT_Q;
     var openOptions = MQC.MQOO_INPUT_AS_Q_DEF;
     mq.Open(hConn,od,openOptions,function(err,hObj) {
       queueHandle = hObj;
       if (err) {
         console.log(formatErr(err));
       } else {
         console.log("MQOPEN of %s successful",qName);
         // And now we can ask for the messages to be delivered.
         getMessages();
       }
     });
   }
});
github ibm-messaging / mq-mqi-nodejs / samples / amqspub.js View on Github external
console.log("MQCONN to %s successful ", qMgr);

     // Define what we want to open, and how we want to open it.
     //
     // For this sample, we use only the ObjectString, though it is possible
     // to use the ObjectName to refer to a topic Object (ie something
     // that shows up in the DISPLAY TOPIC list) and then that
     // object's TopicStr attribute is used as a prefix to the TopicString
     // value supplied here.
     // Remember that the combined TopicString attribute has to match what
     // the subscriber is using.
     var od = new mq.MQOD();
     od.ObjectString = topicString;
     od.ObjectType = MQC.MQOT_TOPIC;
     var openOptions = MQC.MQOO_OUTPUT;
     mq.Open(hConn,od,openOptions,function(err,hObj) {
       if (err) {
         console.error(formatErr(err));
       } else {
         console.log("MQOPEN of %s successful",topicString);
         publishMessage(hObj);
       }
       cleanup(hConn,hObj);
     });
   }
});
github ibm-messaging / mq-mqi-nodejs / samples / amqsget.js View on Github external
mq.Conn(qMgr, function(err,hConn) {
   if (err) {
      console.log(formatErr(err));
   } else {
     console.log("MQCONN to %s successful ", qMgr);

     // Define what we want to open, and how we want to open it.
     var od = new mq.MQOD();
     od.ObjectName = qName;
     od.ObjectType = MQC.MQOT_Q;
     var openOptions = MQC.MQOO_INPUT_AS_Q_DEF;
     mq.Open(hConn,od,openOptions,function(err,hObj) {
       if (err) {
         console.log(formatErr(err));
       } else {
         console.log("MQOPEN of %s successful",qName);
         // And loop getting messages until done.
         getMessages(hObj);
       }
       cleanup(hConn,hObj);
     });
   }
});
github ibm-messaging / mq-mqi-nodejs / samples / amqsbra.js View on Github external
mq.Conn(qMgr, function(err,hConn) {
   if (err) {
     console.log(formatErr(err));
   } else {
     console.log("MQCONN to %s successful ", qMgr);
     connectionHandle = hConn;

     // Define what we want to open, and how we want to open it.
     var od = new mq.MQOD();
     od.ObjectName = qName;
     od.ObjectType = MQC.MQOT_Q;
     var openOptions = MQC.MQOO_BROWSE; // Indicate non-destructive retrieval needed
     mq.Open(hConn,od,openOptions,function(err,hObj) {
       queueHandle = hObj;
       if (err) {
         console.log(formatErr(err));
       } else {
         console.log("MQOPEN of %s successful",qName);
         // And now we can ask for the messages to be delivered.
         getMessages();
       }
     });
   }
});
github ibm-messaging / mq-dev-patterns / Node.js / basicget.js View on Github external
return new Promise(function resolver(resolve, reject){
    debug_info('Opening MQ Connection');
    // Define what we want to open, and how we want to open it.
    let od = new mq.MQOD();
    od.ObjectName = MQDetails.QUEUE_NAME;
    od.ObjectType = MQC.MQOT_Q;
    let openOptions = MQC.MQOO_INPUT_AS_Q_DEF;
    mq.Open(hConn, od, openOptions, function(err, hObj) {
      if (err) {
        debug_warn('Error Detected Opening MQ Connection', err);
        reject();
      } else {
        resolve(hObj);
      }
    });
  });
}
github ibm-messaging / mq-dev-patterns / Node.js / basicresponse.js View on Github external
debug_info('ReplyToQMgr ', mqmdRequest.ReplyToQMgr);
  debug_info('Request ', msgObject);
  debug_info(typeof msgObject, msgObject.value);

  var replyObject = {
    'Greeting': "Reply",
    'result': performCalc(msgObject.value)
  }
  var msg = JSON.stringify(replyObject);

  var od = new mq.MQOD();
  od.ObjectName = mqmdRequest.ReplyToQ;
  od.ObjectType = MQC.MQOT_Q;
  var openOptions = MQC.MQOO_OUTPUT;

  mq.Open(hConn, od, openOptions, function(err, hObjReply) {
    debug_info('Inside MQ Open for Reply Callback function');
    if (err) {
      debug_warn('Error Detected Opening MQ Connection for Reply', err);
    } else {
      debug_info("MQOPEN of %s successful", mqmdRequest.ReplyToQMgr);

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

      mqmd.CorrelId = mqmdRequest.CorrelId;
      mqmd.MsgId = mqmdRequest.MsgId;

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

      mq.Put(hObjReply, mqmd, pmo, msg, function(err) {
github ibm-messaging / mq-dev-patterns / Node.js / basicrequest.js View on Github external
mq.Open(hConn, odDynamic, openDynamicOptions, function(err, hObjDynamic) {
      debug_info('Inside MQ Open Dynamic Queue Callback function');
      if (err) {
        debug_warn('Error Detected Opening MQ Connection', err);
      } else {
        debug_info("MQOPEN of Dynamic Queue %s successful", hObjDynamic._name);
        debug_info(hObjDynamic);

        // Define what we want to open, and how we want to open it.
        var od = new mq.MQOD();
        od.ObjectName = MQDetails.QUEUE_NAME;
        od.ObjectType = MQC.MQOT_Q;

        var openOptions = MQC.MQOO_OUTPUT;

        mq.Open(hConn, od, openOptions, function(err, hObj) {
          debug_info('Inside MQ Open Callback function');
          if (err) {
            debug_warn('Error Detected Opening MQ Connection', err);
          } else {
            debug_info("MQOPEN of %s successful", MQDetails.QUEUE_NAME);
            putMessage(hObj, hObjDynamic, (err, msgId) => {
              if (msgId) {
                awaitResponse(hObjDynamic, msgId, (err, msg) => {
                  cleanup(hConn, hObj, hObjDynamic);
                });
              }
            });
          }
        });
      }
    });
github ibm-messaging / mq-dev-patterns / Node.js / boilerplate.js View on Github external
switch (type) {
        case 'PUT':
        case 'PUBLISH':
        case 'DYNREP':
          openOptions = MQC.MQOO_OUTPUT;
          break;
        case 'GET':
          openOptions = MQC.MQOO_INPUT_AS_Q_DEF;
          break;
        case 'DYNPUT':
          openOptions = MQC.MQOO_INPUT_EXCLUSIVE;
          break;
      }

      debug_info('Attempting connection to MQ ', od.ObjectName);
      mq.Open(hConn, od, openOptions, function(err, hObj) {
        debug_info('Inside MQ Open Callback function');
        if (err) {
          reject(err);
        } else {
          debug_info("MQOPEN of %s successful", me.MQDetails.QUEUE_NAME);
          let data = {
            'hObj': hObj
          };
          resolve(data);
        }
      });
    });
  }