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.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);
});
}
});
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));
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();
}
});
}
});
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.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.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();
}
});
}
});
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);
}
});
});
}
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) {
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);
});
}
});
}
});
}
});
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);
}
});
});
}