Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Contributors:
Mark Taylor - Initial Contribution
*/
/*
* This is an example of a Node.js program to inquire about the attributes of an IBM MQ
* object.
*
* The queue manager name can be given as a parameter on the
* command line. Defaults are coded in the program.
*
*/
// Import the MQ package
var mq = require('ibmmq');
var MQC = mq.MQC; // Want to refer to this export directly for simplicity
// The queue manager to be used. This can be overridden on command line.
var qMgr = "QM1";
function formatErr(err) {
return "MQ call failed in " + err.message;
}
// When we're done, close queues and connections
function cleanup(hConn,hObj) {
mq.Close(hObj, 0, function(err) {
if (err) {
console.log(formatErr(err));
} else {
console.log("MQCLOSE successful");
// This application is based on the samples
// https://github.com/ibm-messaging/mq-mqi-nodejs/blob/master/samples/amqsconn.js
// and
// https://github.com/ibm-messaging/mq-mqi-nodejs/blob/master/samples/amqspub.js
//
// Values for Queue Manager, Topic, Host, Port and Channel are
// passed in as envrionment variables.
const fs = require('fs');
// Import the MQ package
var mq = require('ibmmq');
// Load up missing envrionment variables from the env.json file
var env = require('../env.json');
var MQC = mq.MQC; // Want to refer to this export directly for simplicity
// Set up debug logging options
var debug_info = require('debug')('amqspub:info');
var debug_warn = require('debug')('amqspub:warn');
// Set up Constants
const CCDT = "MQCCDTURL";
const FILEPREFIX = "file://";
// Load the MQ Endpoint details either from the envrionment or from the
// env.json file. The envrionment takes precedence. The json file allows for
// mulitple endpoints ala a cluster. A Connection string is built using
// HOST(PORT) values for all the specified endpoints.
var MQDetails = {};
['QMGR', 'TOPIC_NAME', 'HOST', 'PORT',
'CHANNEL', 'KEY_REPOSITORY', 'CIPHER'].forEach(function(f) {
Mark Taylor - Initial Contribution
*/
/*
* This is an example of a Node.js program to get messages from an IBM MQ
* queue using an asynchronous method.
*
* The queue and queue manager name can be given as parameters on the
* command line. Defaults are coded in the program.
*
* Each MQI call prints its success or failure.
*/
// Import the MQ package
var mq = require('ibmmq');
var MQC = mq.MQC; // Want to refer to this export directly for simplicity
// Import any other packages needed
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
// The default queue manager and queue to be used
var qMgr = "QM1";
var qName = "DEV.QUEUE.1";
var msgId = null;
// Some global variables
var connectionHandle;
var queueHandle;
var waitInterval = 3; // max seconds to wait for a new message
var ok = true;
* Header methods in an MQ program
*
* The queue and queue manager name can be given as parameters on the
* command line. Defaults are coded in the program.
*
* A single message is put, containing a "hello" and timestamp. It is preceded
* by a DLH structure as would normally be done when an application cannot
* process a received message. The message is then retrieved and printed.
*
* Each MQI call prints its success or failure.
*
*/
// Import the MQ package
var mq = require('ibmmq');
var MQC = mq.MQC; // Want to refer to this export directly for simplicity
// Import any other packages needed
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
// The queue manager and queue to be used. These can be overridden on command line.
var qMgr = "QM1";
var qName = "DEV.QUEUE.1";
function formatErr(err) {
return "MQ call failed in " + err.message;
}
function toHexString(byteArray) {
return byteArray.reduce((output, elem) =>
(output + ('0' + elem.toString(16)).slice(-2)),
Mark Taylor - Initial Contribution
*/
/*
* This is an example of a Node.js program to get messages from an IBM MQ
* queue.
*
* The queue and queue manager name can be given as parameters on the
* command line. Defaults are coded in the program.
*
* Each MQI call prints its success or failure.
*/
// Import the MQ package
var mq = require('ibmmq');
var MQC = mq.MQC; // Want to refer to this export directly for simplicity
// Import any other packages needed
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
// The default queue manager and queue to be used
var qMgr = "QM1";
var qName = "DEV.QUEUE.1";
// Global variables
var ok = true;
function formatErr(err) {
return "MQ call failed in " + err.message;
}
* This is an example of a Node.js program to use message
* properties.
*
* The queue and queue manager name can be given as parameters on the
* command line. Defaults are coded in the program.
*
* A single message is put with some properties set on it. The message
* is then retrieved, and the properties displayed. The queue ought to be
* empty before starting to run this program, to ensure the same message is
* retrieved as we put.
*
*/
// Import the MQ package
var mq = require('ibmmq');
var MQC = mq.MQC; // Want to refer to this export directly for simplicity
// Import any other packages needed
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
// The queue manager and queue to be used. These can be overridden on command line.
var qMgr = "QM1";
var qName = "DEV.QUEUE.1";
var hConn;
// Global variables
var ok = true;
var propsToRead = true;
function formatErr(err) {
Mark Taylor - Initial Contribution
*/
/*
* This is an example of a Node.js program to browse messages from an IBM MQ
* queue using an asynchronous method. This is a non-destructive operation
*
* The queue and queue manager name can be given as parameters on the
* command line. Defaults are coded in the program.
*
* Each MQI call prints its success or failure.
*/
// Import the MQ package
var mq = require('ibmmq');
var MQC = mq.MQC; // Want to refer to this export directly for simplicity
// Import any other packages needed
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
// The default queue manager and queue to be used
var qMgr = "QM1";
var qName = "DEV.QUEUE.1";
// Some global variables
var connectionHandle;
var queueHandle;
var waitInterval = 3; // max seconds to wait for a new message
var ok = true;
var exitCode = 0;
// https://github.com/ibm-messaging/mq-mqi-nodejs/blob/master/samples/amqsget.js
//
// Values for Queue Manager, Queue, Host, Port and Channel are
// passed in as envrionment variables.
const fs = require('fs');
// Import the MQ package
const mq = require('ibmmq');
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
// Load up missing envrionment variables from the env.json file
var env = require('../env.json');
var MQC = mq.MQC;
var waitInterval = 5;
// Set up debug logging options
var debug_info = require('debug')('amqsreq:info');
var debug_warn = require('debug')('amqsreq:warn');
// Set up Constants
const CCDT = "MQCCDTURL";
const FILEPREFIX = "file://";
// Load the MQ Endpoint details either from the envrionment or from the
// env.json file. The envrionment takes precedence. The json file allows for
// mulitple endpoints ala a cluster.
// The Connection string is built using HOST(PORT) settings for all
// the endpoints.
var MQDetails = {};
* This is an example of a Node.js program to put messages to an IBM MQ
* queue.
*
* The queue and queue manager name can be given as parameters on the
* command line. Defaults are coded in the program.
*
* A single message is put, containing a "hello" and timestamp.
* Each MQI call prints its success or failure.
*
* This program also demonstrates how authentication can be achieved with
* a userid/password option.
*/
// Import the MQ package
var mq = require('ibmmq');
var MQC = mq.MQC; // Want to refer to this export directly for simplicity
// The queue manager and queue to be used. These can be overridden on command line.
var qMgr = "QM1";
var qName = "DEV.QUEUE.1";
function formatErr(err) {
return "MQ call failed in " + err.message;
}
function toHexString(byteArray) {
return byteArray.reduce((output, elem) =>
(output + ('0' + elem.toString(16)).slice(-2)),
'');
}
// Define some functions that will be used from the main flow
/*
* This is an example of a Node.js program to publish messages to an IBM MQ
* topic.
*
* The topic and queue manager name can be given as parameters on the
* command line. Defaults are coded in the program.
*
* A single message is published, containing a "hello" and timestamp.
* Each MQI call prints its success or failure.
*
*/
// Import the MQ package
var mq = require('ibmmq');
var MQC = mq.MQC; // Want to refer to this export directly for simplicity
// The queue manager and topic to be used. These can be overridden on command line.
// The DEV.BASE.TOPIC object defines a tree starting at dev/
var qMgr = "QM1";
var topicString = "dev/JSTopic";
function formatErr(err) {
if (err.mqcc == MQC.MQCC_WARNING)
return "MQ call returned warning in " + err.message;
else
return "MQ call failed in " + err.message;
}
// Define some functions that will be used from the main flow
function publishMessage(hObj) {