Monday, 4 January 2016

MQ Basic Commands



 Command to lists the MQ series version

[mqm@middlewaretech mqm]$ dspmqver
Name:        WebSphere MQ
Version:     7.5.0.2
Level:       p750-002-130704.TRIAL
BuildType:   IKAP - (Production)
Platform:    WebSphere MQ for Linux (x86 platform)
Mode:        32-bit
O/S:         Linux 2.6.18-194.el5
InstName:    Installation1
InstDesc:   
Primary:     Yes
InstPath:    /opt/mqm
DataPath:    /var/mqm
MaxCmdLevel: 750

 Command to lists the queue manager name and status

[mqm@middlewaretech mqm]$ dspmq
QMNAME(QMA)                                               STATUS(Running)
QMNAME(QMA1)                                              STATUS(Running)

Command to create Queue Manager

Syntax : crtmqm <Queue Manager name>

[mqm@middlewaretech mqm]$ crtmqm Excercise1QM

There are 88 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager created.
Directory '/var/mqm/qmgrs/Excercise1QM' created.
The queue manager is associated with installation 'Installation1'.
Creating or replacing default objects for queue manager 'Excercise1QM'.
Default objects statistics : 74 created. 0 replaced. 0 failed.
Completing setup.
Setup completed.

[mqm@middlewaretech mqm]$ dspmq
QMNAME(QMA)                                               STATUS(Running)
QMNAME(QMA1)                                              STATUS(Running)
QMNAME(Excercise1QM)                                      STATUS(Ended immediately)
[mqm@middlewaretech mqm]$

 command to stop, start & delete queue manager

To start :
syntax : strmqm < Queue Manager name>


[mqm@middlewaretech mqm]$ strmqm Excercise1QM

There are 88 days left in the trial period for this copy of WebSphere MQ.
WebSphere MQ queue manager 'Excercise1QM' starting.
The queue manager is associated with installation 'Installation1'.
5 log records accessed on queue manager 'Excercise1QM' during the log replay phase.
Log replay for queue manager 'Excercise1QM' complete.
Transaction manager state recovered for queue manager 'Excercise1QM'.
WebSphere MQ queue manager 'Excercise1QM' started using V7.5.0.2.

check queue manager status:

[mqm@middlewaretech mqm]$ dspmq
QMNAME(QMA)                                               STATUS(Running)
QMNAME(QMA1)                                              STATUS(Running)
QMNAME(Excercise1QM)                                      STATUS(Running)
[mqm@middlewaretech mqm]$

To Stop:

syntax : endmqm  < Queue Manager name>


[mqm@middlewaretech mqm]$ endmqm QMA1
Quiesce request accepted. The queue manager will stop when all outstanding work
is complete.

[mqm@middlewaretech mqm]$ dspmq
QMNAME(QMA)                                               STATUS(Running)
QMNAME(QMA1)                                              STATUS(Ended normally)
QMNAME(Excercise1QM)                                      STATUS(Running)
[mqm@middlewaretech mqm]$


To Delete :

syntax : dltmqm  < Queue Manager name>

[mqm@middlewaretech mqm]$ dltmqm Excercise1QM
WebSphere MQ queue manager running.

[mqm@middlewaretech mqm]$ dltmqm QMA1
WebSphere MQ queue manager 'QMA1' deleted.

[mqm@middlewaretech mqm]$ dspmq
QMNAME(QMA)                                               STATUS(Running)
QMNAME(Excercise1QM)                                      STATUS(Running)
[mqm@middlewaretech mqm]$

Command to create  local queue (MQSC command)

Syntax : define qlocal or ql <queuename>

[mqm@middlewaretech mqm]$ runmqsc QMA

5724-H72 (C) Copyright IBM Corp. 1994, 2011.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QMA.


define qlocal(QMAQL1)
     1 : define qlocal(QMAQL1)
AMQ8006: WebSphere MQ queue created.


end
     2 : end
No MQSC commands read.
No commands have a syntax error.
All valid MQSC commands were processed.

Command to delete  local queue (MQSC command)

[mqm@middlewaretech mqm]$ runmqsc QMA
5724-H72 (C) Copyright IBM Corp. 1994, 2011.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QMA.

delete ql(QMAQL1)
1 : delete ql(QMAQL1)
AMQ8007: WebSphere MQ queue deleted.

end
     2 : end
No  MQSC commands read.
No commands have a syntax error.
One valid MQSC command could not be processed.
[mqm@middlewaretech bin]$

Command to Put messages onto a queue

syntax : amqsput <queuename> <queuemanager name>

[mqm@middlewaretech bin]$ pwd
/opt/mqm/samp/bin

[mqm@middlewaretech bin]$ ./amqsput   QMAQL1 QMA
Sample AMQSPUT0 start
target queue is QMAQL1
Test1 test2

Sample AMQSPUT0 end

[mqm@middlewaretech bin]$ ./amqsput QMAQL1 QMA
Sample AMQSPUT0 start
target queue is QMAQL1
hello world

Sample AMQSPUT0 end

Command to browse  messages  onto a queue

syntax : amqsbcg or amqsgbr <queuename> <queuemanager name>


[mqm@middlewaretech bin]$ ./amqsgbr QMAQL1 QMA
Sample AMQSGBR0 (browse) start
QMA
Messages for QMAQL1                                         
1 <Test1 test2>
2 <hello world>
no more messages
Sample AMQSGBR0 (browse) end
  

Command to delete messages from a queue

The amqsget or amqsgetc commands can be used to clear all the messages in a queue: each
messages deleted after it is read. There is another way to delete all the messages in the queue.
Actually, it is faster because the messages are not read. However, only an MQ Administrator can use
this method because it is done under the runmqsc command.


 [mqm@middlewaretech bin]$ runmqsc QMA
5724-H72 (C) Copyright IBM Corp. 1994, 2011.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QMA.


CLEAR QLOCAL(QMAQL1)
     1 : CLEAR QLOCAL(QMAQL1)
AMQ8022: WebSphere MQ queue cleared.
end
     2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.

[mqm@middlewaretech bin]$ ./amqsgbr QMAQL1 QMA
Sample AMQSGBR0 (browse) start
QMA
no more messages
Sample AMQSGBR0 (browse) end




No comments: