This should probably be my first blog post about MQ, but I confess: I was too excited to start writing.
Lately I’ve had little time to post new stuff. This is probably just an excuse to write something again.
In the following lines, I’ll give you an introduction to the most used MQ commands.
There are different types of MQ commands:
- Informational commands — These are commands to get information about the IBM MQ installation and queue managers
- Control commands — Commands to stop, start and configure MQ
- Sample commands — Commands that are supplied with source code as programming samples but are somewhat useful for the non-programmer
Information commands
Informational commands are commands that are used to display several types of information about the workings of MQ. The following list is not exhaustive; only the most common commands are shown.
- dspmq
Display status information about queue managers - dspmqaut
Displays the authorizations (permissions) of a specific IBM MQ object. - dspmqinf
Display IBM MQ configuration information (AIX, Linux, and Windows only). - dspmqinst
Display installation entries from mqinst.ini on AIX, Linux, and Windows, and display license entitlement information. - dspmqver
Display IBM MQ version and build information.
dspmq
Analogous to the ls UNIX and Linux command, dspmq is the probably the most used MQ command. It display the status of all queue managers configured on one machine of the instances of a multi-instance queue manager (if you use the -x command line option).
Here’s an example:
mqm@ubuntuvm1:~$ dspmq
QMNAME(MQ01) STATUS(Running)
QMNAME(mqcl1n01) STATUS(Running)
As you can see, I have two queue managers running.
dspmqaut
The dspmqaut command will be covered in a future article about object authorizations. Basically it is a command that can be replaced with MQSC commands and only exists for backwards compatibility with older (7.x and older) MQ versions.
dspmqinf
The dspmqinf command is used to display information about a queue manager. It’s used in conjunction with the addmqinf command, which is a necessary step for multi-instance and failover high-availability configurations.
dspmqinst
This command shows information about the MQ installations present in a machine.
mqm@ubuntuvm1:~$ dspmqinst
InstName: Installation1
InstDesc:
Identifier: 1
InstPath: /opt/mqm
Version: 9.2.0.0
Primary: Yes
State: Available
LicenseType: Production
Entitlement: IBM MQ Advanced
Fixes:
As you can see for the above, there is only one MQ installation of MQ version 9.2.0.0 in the /opt/mqm directory.
dspmqver
Finally, the dspmqver displays information about the MQ version(s) installed in the system.
mqm@ubuntuvm1:~$ dspmqver
Name: IBM MQ
Version: 9.2.0.0
Level: p920-L200709
BuildType: IKAP — (Production)
Platform: IBM MQ for Linux (x86-64 platform)
Mode: 64-bit
O/S: Linux 5.4.0–72-generic
O/S Details: Ubuntu 20.04.2 LTS (Focal Fossa)
InstName: Installation1
InstDesc:
Primary: Yes
InstPath: /opt/mqm
DataPath: /var/mqm
MaxCmdLevel: 920
LicenseType: Production
Although some of this information is also displayed in the output of the dspmqinst command, this one is slightly different.
Control commands
Control commands are the ones you can use to stop, start, and configure MQ.
The most used ones are:
- strmqm
Start a queue manager - endmqm
Stop a queue manager - strmqweb
Start the MQ web console and the REST Admin interface - endmqweb
Stop the MQ web console and the REST Admin interface - addmqinf
Add MQ configuration information - amqfsck
Check file systems for MQ support - crtmqm
Create a queue manager - dltmqm
Delete a queue manager
strmqm
This command is used to start a queue manager.
strmqm MQ1
The above command starts the MQ1 queue manager.
endmqm
This command is used to stop a queue manager. Like the strmqm command its syntax is very simple:
endmqm MQ1
The endmqm command has other options, but those should be used only if absolutely necessary.
strmqweb
The strmqweb command is used to start the IBM MQ Web Console and the REST Administration service. It has no command line options.
dspmqweb
This command is used to display the status of the IBM MQ Web Console.
endmqweb
This, as its name suggests, is used to stop the IBM MQ Web Console and REST Administration service.
addmqinf
This command is used when installing highly available or multi-instance queue managers.
It’s used in tandem with the dspmqinf command.
amqfsck
This command is useful when you want to test the file system’s compatibility with the MQ multi-instance feature.
ctrmqm
This is one of the most important MQ commands. It’s used to create a queue manager. This command takes at least the name of the queue manager to be created.
dltmqm
This command is used to remove a queue manager from the system.
WARNING: it’s effects are irreversible. After you delete one queue manager, in order to use it again, you have to recreate it.
Sample commands
There are some sample commands that are useful, specially for troubleshooting and testing.
- amqsput
Put messages into queues - amqsget
Get messages from queues - amqsrua
Display metrics and monitoring info generated by MQ - amqsmon
Get statistics or accounting information generated by MQ
amqsput
This command allows you to write messages to a queue. It’s invoked as follows:
/usr/mqm/samp/bin/amqsput <queue> [<queue manager>]
on AIX.
On Linux, use the following:
/opt/mqm/samp/bin/amqsput <queue> [<queue manager>]
The <queue manager> parameter is optional.
The messages to be sent are read from standard in, one message per line.
This utility is supplied with source code in C, in the file /usr/mqm/samp/amqsput0.c (in the default AIX installation location) or /opt/mqm/samp/amqsput0.c (in the default Linux installation location).
amqsget
This sample utility is the counterpart of amqsput.
It’s used to read messages from a queue.
Its invocation is just as amqsput:
/opt/mqm/samp/bin/amqsget <queue> [<queue manager>]
The <queue manager> parameter is optional.
This utility is supplied with source code in C, in the file /usr/mqm/samp/amqsget0.c (in the default AIX installation location) or /opt/mqm/samp/amqsget0.c (in the default Linux installation location).
amqsrua
This is utility allows you to collect performance information from MQ’s system performance topics.
It will be described in a future post about MQ performance.
aqmsmon
This is tool that allows you to get MQ’s statistics and accounting data.
It will be detailed in a future post about MQ statistics and accounting.
Pingback: MQGem Monthly (December 2021) | MQGem Software