We will list some of the useful mq commands which we use regularly during day to day operations .
1.Create QMGR
crtmqm QMGRNAME
2.display QMGR status
dspmq
3.display MQ version ,Instance Name ,Binary path ,Data Path etc
dspmqver
4.Create Queue
DEFINE QLOCAL(QNAME)
5.Create Listener
DEFINE LISTENER(LISTERNAME) PORT(PORTNO) TRPTYPE(TCP)
6.Stopping qmgr
endmqm QMGRNAME
7.Delete QMGR
dltmqm QMGRNAME
8.Command to connect to QMGR to create MQ objects
runmqsc QMGRNAME
9.Command to get the message from Queue
amqsget QNAME QMGRNAME
10.Command to put the message to Queue
amqsput QNAME QMGRNAME
11.Browse the messages from Queue
amqsbcg QNAME QMGRNAME
12.Display all the queues in the QMGR
display ql(*)
13.Display all the SYSTEM Queues in the QMGR
display ql(SYSTEM.*)
14.Display CURDEPTH & MAXDEPTH property of the queue
DIS QL(Queue Name) CURDEPTH MAXDEPTH
CURDEPTH stands for Current depth of the particular queue and MAXDEPTH stands for Maximum depth of the particular queue
[mqm@ip-172-31-14-154 ~]$ echo "dis ql(TESTQ) CURDEPTH maxdepth " | runmqsc IBMMQ.QM1
5724-H72 (C) Copyright IBM Corp. 1994, 2020.
Starting MQSC for queue manager IBMMQ.QM1.
1 : dis ql(TESTQ) CURDEPTH maxdepth
AMQ8409I: Display Queue details.
QUEUE(TESTQ) TYPE(QLOCAL)
CURDEPTH(0) MAXDEPTH(5000)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
[mqm@ip-172-31-14-154 ~]$
15.Working with Persistent queue
ALTER QL(Queue Name) DEFPSIST(YES)
The above command is to Alter the localqueue along with Persistence
DIS QL(Queue Name) DEFPSIST The above command is to Display the local queue along with Persistence
Note : Put some messages using amqsput command and re-start queue manager Messages will be present
16.Working with Dead Letter queue
DEF QL(QM1DLQ) DEFPSIST(YES) MAXDEPTH(1000000) MAXMSGL(41943040)
Assign DLQ to queue manager ALT QMGR DEADQ(QM1DLQ)
To display DLQ DIS QMGR DEADQ
17.Command to create Alias Queue
DEFINE QA (Queue Name) TARGQ(Queue Name),
Example: DEF QA (IN) TARGETQ(INDIA)
18.Command to display Alias Queue
DIS QA( IN) DIS QA(*) : Will display all Alias queues of the queue manager
19.Command to create Remote Queue
DEF QR (Queue Name)
Example : DEF QR (QR1)
; Command to display Remote queue DIS QR( QR!) DIS QR(*) : Will display all Remote queues of the queue manager
20.Want to put test n number of Test messages using script
#!/bin/bash
for i in `seq 10` ; do
echo "Sending $i message"
echo "Test MSG $i" |/opt/mqm/samp/bin/amqsput TESTQ IBMMQ.QM1 >/dev/null 2>&1
done
Save above script as put.sh and execute . Refer below output.
--------------------------------------------------------------
mqm@ip-172-31-14-154 tmp]$ echo "dis ql(TESTQ) CURDEPTH maxdepth " | runmqsc IBMMQ.QM1
5724-H72 (C) Copyright IBM Corp. 1994, 2020.
Starting MQSC for queue manager IBMMQ.QM1.
1 : dis ql(TESTQ) CURDEPTH maxdepth
AMQ8409I: Display Queue details.
QUEUE(TESTQ) TYPE(QLOCAL)
CURDEPTH(0) MAXDEPTH(5000)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
[mqm@ip-172-31-14-154 tmp]$ vi put.sh
[mqm@ip-172-31-14-154 tmp]$ sh put.sh
Sending 1 message
Sending 2 message
Sending 3 message
Sending 4 message
Sending 5 message
Sending 6 message
Sending 7 message
Sending 8 message
Sending 9 message
Sending 10 message
[mqm@ip-172-31-14-154 tmp]$ /opt/mqm/samp/bin/amqsget TESTQ IBMMQ.QM1
Sample AMQSGET0 start
message <Test MSG 1>
message <Test MSG 2>
message <Test MSG 3>
message <Test MSG 4>
message <Test MSG 5>
message <Test MSG 6>
message <Test MSG 7>
message <Test MSG 8>
message <Test MSG 9>
message <Test MSG 10>
no more messages
Sample AMQSGET0 end
[mqm@ip-172-31-14-154 tmp]$
21.Dump QMGR Configuration
SYNTAX: dmqmqcfg -m QMGRNAME -a
[mqm@ip-172-31-14-154 tmp]$ dspmq
QMNAME(IBMMQ.QM1) STATUS(Running)
[mqm@ip-172-31-14-154 tmp]$ dmpmqcfg -m IBMMQ.QM1 -a > /tmp/IBMMQ.QM1.dmp
[mqm@ip-172-31-14-154 tmp]$ vi /tmp/IBMMQ.QM1.dmp
[mqm@ip-172-31-14-154 tmp]$ ls -ld /tmp/IBMMQ.QM1.dmp
-rw-rw-r--. 1 mqm mqm 97078 Dec 30 11:01 /tmp/IBMMQ.QM1.dmp
[mqm@ip-172-31-14-154 tmp]$
22.Display properties of the queue manager
DIS QMGR
DIS is the command to “display” the properties of the QueueManager like Trigger Interval, Max Handles, Max message length,TCP port etc.
23.Delete queue
DELETE QL(Queue Name) --> Throw an error if queue is not empty, so first clear the queue, then delete.
CLEAR QL(Queue Name)
24.Display Local queue where curdepth greater than 1
dis ql(*) where ( cudepth gt 1 )
25.Checking all channel status
dis chs(*)
26.Check How many Process connected to Queue for put or get
dis qs(TESTQ)
dis qs(TESTQ) TYPE(handle)