Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mq.Connx(qMgr, cno, function(err,hConn) {
if (err) {
console.error(formatErr(err));
} else {
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);
});
}
});
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);
});
}
});
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);
});
}
});
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 = qName;
od.ObjectType = MQC.MQOT_Q;
var openOptions = MQC.MQOO_SET;
mq.Open(hConn,od,openOptions,function(err,hObj) {
if (err) {
console.log(formatErr(err));
} else {
console.log("MQOPEN of queue manager successful");
setQ(hObj);
}
cleanup(hConn,hObj);
});
}
});
mq.Connx(MQDetails.QMGR, cno, function(err, hConn) {
if (err) {
debug_warn('Error Detected making Connection', err);
} else {
debug_info("MQCONN to %s successful ", MQDetails.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 = MQDetails.TOPIC_NAME;
od.ObjectType = MQC.MQOT_TOPIC;
var openOptions = MQC.MQOO_OUTPUT;
mq.Open(hConn, od, openOptions, function(err, hObj) {
if (err) {
debug_warn('Error Detected Opening MQ Connection', err);
} else {
debug_info("MQOPEN of %s successful", MQDetails.QUEUE_NAME);
publishMessage(hObj);
}
cleanup(hConn, hObj);
});
}
});
mq.Connx(MQDetails.QMGR, cno, function(err, hConn) {
debug_info('Inside Connection Callback function');
if (err) {
debug_warn('Error Detected making Connection', err);
} else {
debug_info("MQCONN to %s successful ", MQDetails.QMGR);
// 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);
}
cleanup(hConn, hObj);
});
}
function respondToRequest(hConn, hObj, msgObject, mqmdRequest) {
debug_info('Preparing response to');
debug_info('MsgID ', toHexString(mqmdRequest.MsgId));
debug_info('CorrelId ', toHexString(mqmdRequest.CorrelId));
debug_info('ReplyToQ ', mqmdRequest.ReplyToQ);
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;
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);
});
mq.Connx(MQDetails.QMGR, cno, function(err, hConn) {
debug_info('Inside Connection Callback function');
if (err) {
debug_warn('Error Detected making Connection', err);
} else {
debug_info("MQCONN to %s successful ", MQDetails.QMGR);
// Open up the Dynamic Response queue
var odDynamic = new mq.MQOD();
odDynamic.ObjectName = MQDetails.MODEL_QUEUE_NAME;
odDynamic.DynamicQName = MQDetails.DYNAMIC_QUEUE_PREFIX;
var openDynamicOptions = MQC.MQOO_INPUT_EXCLUSIVE;
//var openDynamicOptions = null;
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();
return new Promise(function resolver(resolve, reject) {
var od = new mq.MQOD();
debug_info('Opening Connection running mode ', type);
switch (type) {
case 'PUT':
case 'GET':
od.ObjectName = me.MQDetails.QUEUE_NAME;
od.ObjectType = MQC.MQOT_Q;
break;
case 'PUBLISH':
od.ObjectString = me.MQDetails.TOPIC_NAME;
od.ObjectType = MQC.MQOT_TOPIC;
break;
case 'DYNPUT':
od.ObjectName = me.MQDetails.MODEL_QUEUE_NAME;
od.DynamicQName = me.MQDetails.DYNAMIC_QUEUE_PREFIX;