Building on Matt Leming’s excellent blog: Exposing the MQ REST API via the Zowe API Mediation Layer we have an great opportunity to unleash the power of Zowe more using the Zowe CLI – MQ plugin.

The Zowe CLI – MQ Plugin interfaces with the mqweb server as described in Matt’s blog. As described there we have assumed that both Zowe and IBM MQ, including the mqweb server, have previously been installed, configured and started. Information on installing Zowe is here; information on configuring the mqweb server on z/OS is here.

The Zowe CLI is a command line interface running on your client machine that lets you interact with the mainframe remotely using tools such as shell commands and bash scripts. A core set of functionality provides commands for working with data sets, USS, JES, as well as issuing TSO and console commands. Information on installing the Zowe CLI can be found here I would also recommend viewing the tutorial here for a detailed overview.

The Zowe CLI is a framework that allows plugins to be added to the core functionality which open even more capabilities. One such example is the Zowe CLI – MQ Plugin which provides the ability to run MQ Script commands (MQSC) remotely from the z/OS server.

With Zowe is installed locally it is a simple process to install the MQ plugin.

Simply run…

zowe plugins install @zowe/mq

 

Don’t worry about the npm warn messages these will be addressed in later releases. Note that I have subsequently entered the following command:

zowe plugins list which provides details of what plugins I now have installed in the Zowe CLI. Alongside my CICS plugin I now have MQ installed.

With the plugin installed  create an mq profile that contains the details of your mqweb server and credentials using this as your template

zowe profiles create mq-profile mq --host mq123 --port 1234 --user ibmuser --password myp4ss –rejectUnauthorized false

Remember whenever you use zowe, help is there to guide you every step of the way. If you are typing in a command and cannot remember the next word. Just hit enter and the Zowe CLI will guide you.

If this is your first profile for mq it will be created as the default so we don’t need to specify a profile to use with our commands.

 

Now we can get started… Let’s begin by creating a queue to play with.

Substitute:

  • TESTQ with your own queue name.
  • MQ21 With your Queue manager name

 

zowe mq run mqsc MQ21 "DEF QL(COLIN.TESTQ)"

 

Lets put a message on the queue using a curl command just as an example…

curl -i -k -X POST https://<host>:<hostport>/api/v1/ibmmq912/messaging/qmgr/MQ21/queue/COLIN.TESTQ/message -d "Hello world" -H "Content-Type: text/plain" -H "ibm-mq-rest-csrf-token: a" -u user:password

 

Lets examine the queue…
zowe mq run mqsc MQ21 "DIS QSTATUS(COLIN.TESTQ) CURDEPTH LPUTDATE LPUTTIME"

Note the CURDEPTH value indicating the number of messages. Go ahead and add more then examine the queue again.

Finally clean up messages and delete the queue.

zowe mq run mqsc MQ21 "CLEAR QL(COLIN.TESTQ)"

zowe mq run mqsc  MQ21 "DELETE QL(COLIN.TESTQ)"

One major benefit of this plugin is that it allows script commands to be submitted to a z/OS server running IBM MQ without the need for large footprint clients. It provides access to comprehensive system configuration functionality MQ Script commands (MQSC).  This is only a simple demo but there’s far more than this under the hood.

NPM Registry

The plugin is located either on https://www.npmjs.com/package/@zowe/mq or https://gizaartifactory.jfrog.io/gizaartifactory/api/npm/npm-release/@zowe/mq

Join The Discussion

Your email address will not be published. Required fields are marked *