Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function putMessage(hConn,hObj) {
var msg = "Hello from Node at " + new Date();
var mqmd = new mq.MQMD(); // Defaults are fine.
var pmo = new mq.MQPMO();
var cmho = new mq.MQCMHO();
mq.CrtMh(hConn, cmho,function(err,mh) {
if (err) {
console.log(formatErr(err));
} else {
var smpo = new mq.MQSMPO();
var pd = new mq.MQPD();
// Note how the "value" of each property can change datatype
// without needing to be explicitly stated.
var name="PROP1STRING";
var value="helloStringProperty";
mq.SetMp(hConn,mh,smpo,name,pd,value);
name="PROP2INT";
function putMessage(hObj) {
var msg = "Hello from Node at " + new Date();
var mqmd = new mq.MQMD(); // Defaults are fine.
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) {
console.log(formatErr(err));
} else {
console.log("MsgId: " + toHexString(mqmd.MsgId));
console.log("MQPUT successful");
}
});
}
function publishMessage(hObj) {
var msg = "Hello from Node at " + new Date();
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) {
console.error(formatErr(err));
} else {
console.log("MQPUT successful");
}
});
}
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);
debug_info('MsgId: ', msgId);
debug_info("MQPUT successful");
cb(null, msgId);
}
function putMessage(hObj) {
// var msg = "Hello from Node at " + new Date();
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 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);
} else {
debug_info('MsgId: ', toHexString(mqmd.MsgId));
debug_info("MQPUT successful");
}
});
}
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 {
debug_info('MsgId: ', toHexString(mqmd.MsgId));
return new Promise(function resolver(resolve, reject) {
var pmo = new mq.MQPMO();
var queue = me.mqObj;
// Describe how the Put should behave
pmo.Options = MQC.MQPMO_NO_SYNCPOINT;
if ('REPLY' === mode) {
queue = me.mqDynReplyObj;
} else {
pmo.Options |= MQC.MQPMO_NEW_MSG_ID |
MQC.MQPMO_NEW_CORREL_ID;
}
if ('PUBLISH' === me.modeType) {
pmo.Options |= MQC.MQPMO_WARN_IF_NO_SUBS_MATCHED;
}