Basic MQ commands

This should prob­a­bly be my first blog post about MQ, but I con­fess: I was too excit­ed to start writing.

Late­ly I’ve had lit­tle time to post new stuff. This is prob­a­bly just an excuse to write some­thing again.

In the fol­low­ing lines, I’ll give you an intro­duc­tion to the most used MQ commands.

There are dif­fer­ent types of MQ commands:

  • Infor­ma­tion­al com­mands — These are com­mands to get infor­ma­tion about the IBM MQ instal­la­tion and queue managers
  • Con­trol com­mands — Com­mands to stop, start and con­fig­ure MQ
  • Sam­ple com­mands — Com­mands that are sup­plied with source code as pro­gram­ming sam­ples but are some­what use­ful for the non-programmer

Information commands

Infor­ma­tion­al com­mands are com­mands that are used to dis­play sev­er­al types of infor­ma­tion about the work­ings of MQ. The fol­low­ing list is not exhaus­tive; only the most com­mon com­mands are shown.

  • dsp­mq
    Dis­play sta­tus infor­ma­tion about queue managers
  • dsp­mqaut
    Dis­plays the autho­riza­tions (per­mis­sions) of a spe­cif­ic IBM MQ object.
  • dsp­mqinf
    Dis­play IBM MQ con­fig­u­ra­tion infor­ma­tion (AIX, Lin­ux, and Win­dows only).
  • dsp­mqinst
    Dis­play instal­la­tion entries from mqinst.ini on AIX, Lin­ux, and Win­dows, and dis­play license enti­tle­ment information.
  • dsp­mqver
    Dis­play IBM MQ ver­sion and build information.

dspmq

Anal­o­gous to the ls UNIX and Lin­ux com­mand, dsp­mq is the prob­a­bly the most used MQ com­mand. It dis­play the sta­tus of all queue man­agers con­fig­ured on one machine of the instances of a mul­ti-instance queue man­ag­er (if you use the -x com­mand line option).

Here’s an example:

mqm@ubuntuvm1:~$ dsp­mq
QMNAME(MQ01) STATUS(Running)
QMNAME(mqcl1n01) STATUS(Running)

As you can see, I have two queue man­agers running.

dspmqaut

The dsp­mqaut com­mand will be cov­ered in a future arti­cle about object autho­riza­tions. Basi­cal­ly it is a com­mand that can be replaced with MQSC com­mands and only exists for back­wards com­pat­i­bil­i­ty with old­er (7.x and old­er) MQ versions.

dspmqinf

The dsp­mqinf com­mand is used to dis­play infor­ma­tion about a queue man­ag­er. It’s used in con­junc­tion with the addmqinf com­mand, which is a nec­es­sary step for mul­ti-instance and failover high-avail­abil­i­ty configurations.

dspmqinst

This com­mand shows infor­ma­tion about the MQ instal­la­tions present in a machine.

mqm@ubuntuvm1:~$ dsp­mqinst
Inst­Name: Installation1
InstDesc:
Iden­ti­fi­er: 1
Inst­Path: /opt/mqm
Ver­sion: 9.2.0.0
Pri­ma­ry: Yes
State: Available
License­Type: Production
Enti­tle­ment: IBM MQ Advanced
Fixes:

As you can see for the above, there is only one MQ instal­la­tion of MQ ver­sion 9.2.0.0 in the /opt/mqm directory.

dspmqver

Final­ly, the dsp­mqver dis­plays infor­ma­tion about the MQ version(s) installed in the system.

mqm@ubuntuvm1:~$ dsp­mqver
Name: IBM MQ
Ver­sion: 9.2.0.0
Lev­el: p920-L200709
Build­Type: IKAP — (Pro­duc­tion)
Plat­form: IBM MQ for Lin­ux (x86-64 platform)
Mode: 64-bit
O/S: Lin­ux 5.4.0–72-generic
O/S Details: Ubun­tu 20.04.2 LTS (Focal Fossa)
Inst­Name: Installation1
InstDesc:
Pri­ma­ry: Yes
Inst­Path: /opt/mqm
Data­Path: /var/mqm
Max­CmdLev­el: 920
License­Type: Production

Although some of this infor­ma­tion is also dis­played in the out­put of the dsp­mqinst com­mand, this one is slight­ly different.

Control commands

Con­trol com­mands are the ones you can use to stop, start, and con­fig­ure MQ.

The most used ones are:

  • str­mqm
    Start a queue manager
  • end­mqm
    Stop a queue manager
  • str­mqweb
    Start the MQ web con­sole and the REST Admin interface
  • end­mqweb
    Stop the MQ web con­sole and the REST Admin interface
  • addmqinf
    Add MQ con­fig­u­ra­tion information
  • amqf­sck
    Check file sys­tems for MQ support
  • crt­mqm
    Cre­ate a queue manager
  • dlt­mqm
    Delete a queue manager

strmqm

This com­mand is used to start a queue manager.

str­mqm MQ1

The above com­mand starts the MQ1 queue manager.

endmqm

This com­mand is used to stop a queue man­ag­er. Like the str­mqm com­mand its syn­tax is very simple:

end­mqm MQ1

The end­mqm com­mand has oth­er options, but those should be used only if absolute­ly necessary.

strmqweb

The str­mqweb com­mand is used to start the IBM MQ Web Con­sole and the REST Admin­is­tra­tion ser­vice. It has no com­mand line options.

dspmqweb

This com­mand is used to dis­play the sta­tus of the IBM MQ Web Console.

endmqweb

This, as its name sug­gests, is used to stop the IBM MQ Web Con­sole and REST Admin­is­tra­tion service.

addmqinf

This com­mand is used when installing high­ly avail­able or mul­ti-instance queue managers.

It’s used in tan­dem with the dsp­mqinf command.

amqfsck

This com­mand is use­ful when you want to test the file sys­tem’s com­pat­i­bil­i­ty with the MQ mul­ti-instance feature.

ctrmqm

This is one of the most impor­tant MQ com­mands. It’s used to cre­ate a queue man­ag­er. This com­mand takes at least the name of the queue man­ag­er to be created.

dltmqm

This com­mand is used to remove a queue man­ag­er from the system.

WARNING: it’s effects are irre­versible. After you delete one queue man­ag­er, in order to use it again, you have to recre­ate it.

Sample commands

There are some sam­ple com­mands that are use­ful, spe­cial­ly for trou­bleshoot­ing and testing.

  • amqsput
    Put mes­sages into queues
  • amqs­get
    Get mes­sages from queues
  • amqs­rua
    Dis­play met­rics and mon­i­tor­ing info gen­er­at­ed by MQ
  • amqs­mon
    Get sta­tis­tics or account­ing infor­ma­tion gen­er­at­ed by MQ

amqsput

This com­mand allows you to write mes­sages to a queue. It’s invoked as follows:

/usr/mqm/samp/bin/amqsput <queue> [<queue manager>]

on AIX.

On Lin­ux, use the following:

/opt/mqm/samp/bin/amqsput <queue> [<queue manager>]

The <queue man­ag­er> para­me­ter is optional.

The mes­sages to be sent are read from stan­dard in, one mes­sage per line.

This util­i­ty is sup­plied with source code in C, in the file /usr/mqm/samp/amqsput0.c (in the default AIX instal­la­tion loca­tion) or /opt/mqm/samp/amqsput0.c (in the default Lin­ux instal­la­tion location).

amqsget

This sam­ple util­i­ty is the coun­ter­part of amqsput.

It’s used to read mes­sages from a queue.

Its invo­ca­tion is just as amqsput:

/opt/mqm/samp/bin/amqsget <queue> [<queue manager>]

The <queue man­ag­er> para­me­ter is optional.

This util­i­ty is sup­plied with source code in C, in the file /usr/mqm/samp/amqsget0.c (in the default AIX instal­la­tion loca­tion) or /opt/mqm/samp/amqsget0.c (in the default Lin­ux instal­la­tion location).

amqsrua

This is util­i­ty allows you to col­lect per­for­mance infor­ma­tion from MQ’s sys­tem per­for­mance topics.

It will be described in a future post about MQ performance.

aqmsmon

This is tool that allows you to get MQ’s sta­tis­tics and account­ing data.

It will be detailed in a future post about MQ sta­tis­tics and accounting.

This entry was posted in Basics, Middleware, MQ and tagged , , . Bookmark the permalink.

One Response to Basic MQ commands

  1. Pingback: MQGem Monthly (December 2021) | MQGem Software

Leave a Reply