The Node.js samples are based on https://github.com/ibm-messaging/mq-mqi-nodejs/tree/master/samples and have been tested with Node.js v16.8.1
Install/unzip IBM MQ client
IBM MQ MacOS toolkit for developers download
Add
/opt/mqm/bin
and
/opt/mqm/samp/bin
, to the PATH by editing /etc/paths
export DYLD_LIBRARY_PATH=/opt/mqm/lib64
export MQ_INSTALLATION_PATH=/opt/mqm
Windows client v 9.1.1.0 download
Linux Ubuntu client v 9.1.1.0 download
To run the examples cd to the Node.js directory and install the prerequsites by running :
npm install
basicput.js - Puts message to a queue
basicget.js - Gets message from a queue
basicsubscribe.js - Subscribes to a topic string and gets publications/messages
basicpublish.js - Publishes messages to a topic string
basicrequest.js - Puts a message on a request queue and waits for a response
basicresponse.js - Gets message from a request queue, does something with the message and puts it to the reply queue.
sampleput.js - Puts message to a queue
sampleget.js - Gets message from a queue
samplesubscribe.js - Subscribes to a topic string and gets publications/messages
samplepublish.js - Publishes messages to a topic string
samplerequest.js - Puts a message on a request queue and waits for a response
sampleresponse.js- Gets message from a request queue, does something with the message and puts it to the reply queue.
boilerplate.js - Common class, manages the connection to queue manager, contains generic consumer and producer code.
The put application places a json object onto the queue. To run with logging, run
On Mac and Linux:
DEBUG=amqs*:* node basicput.js
On Windows:
export DEBUG=amqs*:*
node basicput.js
The get application reads a json object from the queue.
To run with logging, run
DEBUG=amqs*:* node basicget.js
The get and put applications have the common MQ boiler plate factorised into a library and make use of promises.
To run with logging, run
DEBUG=sample*:*,boiler:* node sampleput.js
and
DEBUG=sample*:*,boiler:* node sampleget.js
The publish application publishes a json object onto a topic. To run with logging, run
DEBUG=amqs*:* node basicpublish.js
The subscribe application subscribes to a topic.
To run with logging, run
DEBUG=amqs*:* node basicsubscribe.js
The publish and subscribe applications have the common MQ boiler plate factorised into a library and makes use of promises.
To run with logging, run
DEBUG=sample*:*,boiler:* node samplepublish.js
and
DEBUG=sample*:*,boiler:* node samplesubscribe.js
The request application create a dynamic queue for a reply, and places a json object consisting of the request onto a queue, then waits for a response to the request.
To run with logging, run
DEBUG=amqs*:* node basicrequest.js
and
DEBUG=amqs*:* node basicresponse.js
The request / response applications have the common MQ boiler plate factorised into a library and makes use of promises.
To run with logging, run
DEBUG=sample*:*,boiler:* node sampleresponse.js
and
DEBUG=sample*:*,boiler:* node samplerequest.js