MQ Listener management
Before a local Queue
Manager can send messages to a remote Queue Manager, we need to start a
Listener for the remote Queue Manager. The default MQ Listener port number is 1414, and if we use this port, then we do not have
to specify a port number when we issue the start listener command. This section looks at how we
manage the MQ Listeners. We will look at the different ways of defining,
starting, and stopping a Listener.
Defining / Starting an MQ Listener:
There are two ways of defning and starting an MQ Listener:
The first method uses
the run Listener RUNMQLSR command. The
parameters for the command are the type of connectivity (-t), the Queue Manager name (-m), and the port number to be started (-p). So if we want to start a TCP listener on port
1450 for Queue Manager QMA, we would issue:
$ runmqlsr -t tcp -m QMA -p 1450
This command can be put
into a batch fle (SYSA_QMA_START_RUNMQLSR.BAT) and in UNIX can be run with the nohup and & options:
$ nohup runmqlsr -t tcp -m QMA -p 1450 &
The command to start a TCP listener on port 1451 for Queue Manager
QMB is:
$ nohup runmqlsr -t tcp -m QMB -p 1451 &
This command can be put
into a SYSB_QMB_START_RUNMQLSR.BAT batch file.
The second method
creates the Listener from the MQSC environment, using the following RUNMQSCcommand fle:
DEFINE LISTENER (QMA1450) +
TRPTYPE (TCP) +
PORT (1450) +
CONTROL(QMGR)
TRPTYPE (TCP) +
PORT (1450) +
CONTROL(QMGR)
In this text file, we
have given the Listener a name (QMA1450), and assigned a port number to that Listener. The last parameter
shown is CONTROL, which determines how
the Listener is started, with the possible options being MANUAL, QMGR, and STARTONLY, which mean:
·
MANUAL: (default) The Listener is not to be started automatically or
stopped automatically. It is to be controlled by use of the START LISTENER and STOP
LISTENER commands.
·
QMGR: The Listener being defned is to be started and stopped at the
same time as the Queue Manager is started and stopped.
·
STARTONLY: The Listener is to be started at the same time as the Queue
Manager is started, but is not requested to stop when the Queue Manager is
stopped.
If a Listener is to be controlled manually, then it can be started
using the following command issued from the MQSC environment:
: start listener(QMA1450)
So to recap, if we use
an MQ command (RUNMQLSR) to start a Listener,
then we cannot give it a name, and we have to start it manually every time the
Queue Manager is started. If we use a text fle from theMQSC environment, then we can name the Listener
and have it start when the Queue Manager starts.
To start the Listeners,
issue the following commands on QMA and QMB respectively:
start runmqlsr -t tcp -m QMA -p 1450
start runmqlsr -t tcp -m QMB -p 1451
start runmqlsr -t tcp -m QMB -p 1451
Both of these commands
can be contained in batch fles SYSA_QMA_START_RUNMQLSR.BAT andSYSB_QMB_START_RUNMQLSR.BAT respectively.
Depending on the standards at your site, you can create Listeners
according to the second method.
Displaying an MQ Listener:
What we mean by "displaying" an MQ Listener is frstly
checking if the Listener is actually running and secondly displaying the
attributes of the Listener. Let's first look at checking if the Listener is
running.
If the Listener was
started using the RUNMQLSR MQ command:
$ runmqlsr -t tcp -m QMA -p 1450 &
Then this creates a
Listener, whose name is of the form SYSTEM.LISTENER.TCP.<n>. We can check if this listener is running by
issuing the DISPLAY LSSTATUS MQSC command:
: display lsstatus(*)
And you'll see:
AMQ8631: Display listener status details.
LISTENER(SYSTEM.LISTENER.TCP.3) STATUS(RUNNING)
PID(12912)
LISTENER(SYSTEM.LISTENER.TCP.3) STATUS(RUNNING)
PID(12912)
We can see that the
status is RUNNING. And the PID corresponds to the output from the UNIX ps –efcommand:
$ ps -ef | grep -i "runmqlsr"
mqm 12912 1 0 14:14 pts/1 00:00:00 runmqlsr -t tcp -m QMA -p 1450
db2instp 15937 10695 0 14:43 pts/1 00:00:00 grep -i runmqlsr
mqm 12912 1 0 14:14 pts/1 00:00:00 runmqlsr -t tcp -m QMA -p 1450
db2instp 15937 10695 0 14:43 pts/1 00:00:00 grep -i runmqlsr
If the Listener had been
created using the MQSC commands in a fle
(as shown previously), then we could have given the Listener a name (QMA1450). And now we can check if the Listener is
running using theDISPLAY LSSTATUS MQSC command:
: display lsstatus(*)
And you'll see:
AMQ8631: Display listener status details.
LISTENER(QMA1450) STATUS(RUNNING)
PID(2360)
LISTENER(QMA1450) STATUS(RUNNING)
PID(2360)
We could of course have specified our Listener name in place of
the asterisk:
: display lsstatus(QMA1450)
AMQ8631: Display listener status details.
LISTENER(QMA1450) STATUS(RUNNING)
PID(2360) STARTDA(2009-02-19)
STARTTI(16.41.41) DESCR( )
TRPTYPE(TCP) CONTROL(QMGR)
IPADDR(*) PORT(1450)
BACKLOG(100)
AMQ8631: Display listener status details.
LISTENER(QMA1450) STATUS(RUNNING)
PID(2360) STARTDA(2009-02-19)
STARTTI(16.41.41) DESCR( )
TRPTYPE(TCP) CONTROL(QMGR)
IPADDR(*) PORT(1450)
BACKLOG(100)
If the Listener was created using an MQSC command fle, then its
properties can be displayed using the DISPLAY LISTENER MQSC command and
specifying a name:
: display listener(QMA1450)
AMQ8630: Display listener information details.
LISTENER(QMA1450) CONTROL(QMGR)
TRPTYPE(TCP) PORT(1450)
IPADDR( ) BACKLOG(100)
DESCR( ) ALTDATE(2009-02-19)
ALTTIME(16.41.41)
AMQ8630: Display listener information details.
LISTENER(QMA1450) CONTROL(QMGR)
TRPTYPE(TCP) PORT(1450)
IPADDR( ) BACKLOG(100)
DESCR( ) ALTDATE(2009-02-19)
ALTTIME(16.41.41)
If the Listener was started using the RUNMQLSR command, then to
display its attributes we need to append the parameter ALL to the DISPLAY
LSSTATUS command:
: display lsstatus(*) all
AMQ8631: Display listener status details.
LISTENER(SYSTEM.LISTENER.TCP.3) STATUS(RUNNING)
PID(8256) STARTDA(2010-01-07)
STARTTI(16.54.54) DESCR( )
TRPTYPE(TCP) CONTROL(MANUAL)
IPADDR(*) PORT(1450)
BACKLOG(100)
AMQ8631: Display listener status details.
LISTENER(SYSTEM.LISTENER.TCP.3) STATUS(RUNNING)
PID(8256) STARTDA(2010-01-07)
STARTTI(16.54.54) DESCR( )
TRPTYPE(TCP) CONTROL(MANUAL)
IPADDR(*) PORT(1450)
BACKLOG(100)
Stopping an MQ Listener
There are two ways of
stopping a Listener. The frst method uses the ENDMQLSR MQ command, and the second method uses the STOP LISTENER MQSC command.
In the following
example, we want to stop the Listener for Queue Manager QMA using the ENDMQLSR MQ command:
$ endmqlsr –w -m QMA
In the following example we are using the STOP LISTENER MQSC
command to stop a Listener:
: stop listener(QMA1450)
Comments