Академический Документы
Профессиональный Документы
Культура Документы
• We cannot read messages from a Remote Queue (only from a Local Queue)
• We can only put a message onto a Local Queue (not a Remote Queue)
It does not matter at this stage if you do not understand the above points, all will become clear
in the following sections.
There are some standards regarding WebSphere MQ object names:
• Queue names, processes and Queue Manager names can have a maximum length
of 48 characters
MQ queues
MQ queues can be thought of as conduits to transport messages between Queue Managers.
There are four different types of MQ queues and one related object. The four different types
of queues are: Local Queue (QL), Remote Queue (QR), Transmission Queue (TQ), and
Dead Letter Queue, and the related object is a Channel (CH).
One of the fundamental processes of WebSphere MQ is the ability to move messages between
Queue Managers. Let's take a high-level look at how messages are moved, as shown in the
following diagram:
When the application Appl1 wants to send a message to application Appl2, it opens a queue -
the local Queue Manager (QM1) determines if it is a Local Queue or a Remote Queue. When
Appl1 issues an MQPUT command to put a message onto the queue, then if the queue is local,
the Queue Manager puts the message directly onto that queue. If the queue is a Remote
Queue, then the Queue Manager puts the message onto a Transmission Queue.
The Transmission Queue sends the message using the Sender Channel on QM1 to the
Receiver Channel on the remote Queue Manager (QM2). The Receiver Channel puts the
message onto a Local Queue on QM2. Appl2 issues a MQGET command to retrieve the
message from this queue.
Now let's move on to look at the queues used by Q replication and in particular, unidirectional
replication, as shown in the following diagram. What we want to show here is the relationship
between Remote Queues, Transmission Queues, Channels, and Local Queues. As an example,
let's look at the path a message will take from Q Capture on QMA to Q Apply on QMB.
Let's break down these defnitions to the core values to show the relationship between the
different parameters, as shown next:
We defne a Remote Queue by matching up the superscript numbers in the defnitions in the
two Queue Managers:
For defnitions on QMA, QMA is the local system and QMB is the remote system.
For defnitions on QMB, QMB is the local system and QMA is the remote system.
1. Remote Queue Manager name
7. Channel name
Queue names:
• QMB: Decide on the Local Queue name on QMB—CAPA.TO.APPB.RECVQ.
Channels:
• QMB: Defne a Receiver Channel on QMB, QMA.TO.QMB—make sure the channel
type (CHLTYPE) is RCVR.
• QMA: Defne a Sender Channel, which takes the messages from the Transmission
Queue QMB.XMITQ and which points to the IP address and Listening port number
of QMB. The Sender Channel name must be QMA.TO.QMB.
• Each Queue Manager can have a Dead Letter Queue. We use the prefx
DEAD.LETTER.QUEUE with a suffx of the Queue Manager name giving
DEAD.LETTER.QUEUE.QMA.
• Transmission Queues should refect the names of the "to" Queue Manager.
Our Transmission Queue on QMA is called QMB.XMITQ, refecting the Queue
Manager that it is going to, and that it is a Transmission Queue. Using this naming
convention on QMB, the Transmission Queue is called QMA.XMITQ.
• Channels should refect the names of the "from" and "to" Queue Managers.
Our Sender Channel defnition on QMA is QMA.TO.QMB refecting that it is a channel
from QMA to QMB and the Receiver Channel on QMB is also called QMA.TO.QMB.
The Receiver Queue on QMA is called QMB.TO.QMA for a Sender Channel of the
same name on QMB.
• A Replication Queue Map defnition requires a local Send Queue, and a remote
Receive Queue and a remote Administration Queue.
The Send Queue is the queue that Q Capture writes to, the Receive Queue is the
queue that Q Apply reads from, and the Administration Queue is the queue that Q
Apply writes messages back to Q Capture with.
2 Local Queues:
3 Local Queues:
CAPA.TO.APPB.REVCQ
CAPA.ADMINQ
DEAD.LETTER.QUEUE.QMB
CAPA.RESTARTQ
1 Remote Queue:
DEAD.LETTER.QUEUE.QMA
CAPA.ADMINQ.REMOTE
1 Remote Queue:
1 Transmission Queue:
CAPA.TO.APPB.SENDQ.REMOTE
QMA.XMITQ
1 Transmission Queue:
1 Sender Channel:
QMB.XMITQ
QMB.TO.QMA
1 Sender Channel:
1 Receiver Channel:
QMA.TO.QMB
QMA.TO.QMB
1 Receiver Channel:
1 Model Queue:
QMB.TO.QMA
IBMQREP.SPILL.MODELQ
The queues required for Event Publishing are shown in the following table:
The queues and channels required for bidirectional/P2P two-way replication are shown in the
following table:
Only some of these commands are of real interest to us as database administrators! We will go
through these relevant commands in the following sections.
Note that it is sometimes desirable to prefx these commands with the operating system
START command, which opens a new window for the command to be executed in.
The only required parameter is the Queue Manager name (QMgrName), which can be up to
48 characters in length. The optional parameters are:
• -c <text>: Descriptive text (up to 64 characters) for this Queue Manager.
• -ld <LogPath>: The directory used to hold log fles. On Windows, the default is
C:\Program Files\IBM\WebSphere MQ\log (assuming that C is the data drive). On
UNIX systems, the default is /var/mqm/log. User ID mqm and group mqm must
have full authority on these directories, which occurs automatically if the log fles
are in their default locations. If we change the locations of these fles, we must give
these authorities manually.
• -lf <LogFilePages>: The log data is held in a series of fles called log fles.
• -lp <LogPrimaryFiles>: The log fles allocated when the Queue Manager is created.
• -ls <LogSecondaryFiles>: The log fles allocated when the primary fles are
exhausted.
• -z: Suppresses error messages. This fag is used within WebSphere MQ to suppress
unwanted error messages. Because using this fag can result in loss of information,
do not use it when entering commands through the command line.
The command to create a Queue Manager called QMA with a Dead Letter Queue called
DEAD.LETTER.QUEUE.QMA is:
$ crtmqm –u DEAD.LETTER.QUEUE.QMA QMA
Note that this command just tells the Queue Manager that it can use a Dead Letter Queue
called DEAD.LETTER.QUEUE.QMA, which is a Local Queue, and still has to be created, see
the MQ Queue management—to defne a Local Queue section. As we have not specifed any
logging options, we will be using circular logging.
It is not possible to change the type of logging once the Queue Manager has been
defned.
As can be seen from the command description, the CRTMQM command has only a small
number of parameters that can be specifed. A Queue Manager has many more attributes, and
these are automatically set to default values. These default values can be changed using the
ALTER QMGR MQSC command. One such parameter that is assigned when a Queue
Manager is created is the SCHINIT attribute, which controls channel initiators and is
discussed next.
All Queue Managers need a channel initiator to monitor the system-defined initiation queue
SYSTEM.CHANNEL.INITQ, which is the Initiation Queue for all Transmission Queues.
When we start a Queue Manager, a channel initiator is automatically started if the Queue
Manager attribute SCHINIT is set to QMGR (which is the default value). Otherwise, it can be
started using the START CHINIT MQSC command or the RUNMQCHI command.
Starting a Queue Manager
Before we can use a Queue Manager, we need to start it, using the STRMQM command. The
command to start a Queue Manager called QMA is:
$ strmqm QMA
• -i: Immediate shutdown. The Queue Manager stops after it has completed all the
calls currently being processed. Any MQI requests issued after the command has
been issued fail. Any incomplete units of work are rolled back when the Queue
Manager is next started. Control is returned after the Queue Manager has ended.
If we want to suppress error messages, then we just have to add the –z parameter to the
command.
An example of the command to stop Queue Manager QMA is shown next:
$ endmqm –i QMA
Deleting a Queue Manager
The command to delete/drop a Queue Manager is DLTMQM, but before we can issue that
command we need to stop all the Listeners for the Queue Manager and then stop (end) the
Queue Manager.
The following command will stop all the Listeners associated with Queue Manager pointed to
by the –m flag (QMA in this example). The –w flag means the command will wait until all the
Listeners are stopped before returning control:
$ endmqlsr -w -m QMA
MQ logging
The default logging option (circular) can be found in the qm.ini fle on UNIX or the Windows
Registry on Windows. The alternative is linear logging (which DB2 people call archive
logging). The type of logging is determined at Queue Manager creation time and cannot be
altered afterwards.
Issuing commands to a Queue Manager
(runmqsc)
Once we have created a Queue Manager, we will want to perform administrative tasks, such
as creating queues, among others. To enable us to communicate with our Queue Manager, we
use the RUNMQSC MQ command, which opens the MQSC (MQ Script Center) environment.
After entering the MQSC environment, we can issue one of the following MQSC commands:
ALTER, CLEAR, DEFINE, DELETE, DISPLAY, END, PING, REFRESH, RESET, RESOLVE,
RESUME, START, STOP, or SUSPEND. Each of these commands has it's own options, which
are shown in the following table:
AUTHINFO
QREMOTE
CHANNEL QUEUE
AUTHINFO
AUTHINFO AUTHINFO CHSTATUS
CHANNEL QSTATUS
CHANNEL CHANNEL
PROCESS CLUSQMGR
PROCESS PROCESS CONN
NAMELIST
NAMELIST NAMELIST PROCESS
QALIAS
QALIAS QALIAS SERVICE CHANNEL
QLOCAL QLOCAL
QLOCAL QLOCAL NAMELIST QMGR
QMGR LISTENER
QMODEL QMODEL
QMODEL QALIAS SVSTATUS
QREMOTE QREMOTE
QREMOTE QCLUSTER
SERVICE SERVICE LSSTATUS
SERVICE
LISTENER LISTENER QLOCAL
LISTENER QMSTATUS
QMGR
QMODEL
We can either enter the these MQSC commands interactively or pipe the commands into the
MQSC environment.
To invoke the MQSC environment for Queue Manager QMA, issue the RUNQMSC command
as follows:
$ runmqsc QMA
And then enter the command we want. For example, to defne a Local Queue called
CAPA.ADMINQ, we would enter:
DEFINE QLOCAL(CAPA.ADMINQ) REPLACE PUT(ENABLED)
GET(ENABLED) SHARE DEFSOPT(SHARED) DEFPSIST(YES)
1 : DEFINE QLOCAL(CAPA.ADMINQ) REPLACE PUT(ENABLED)
GET(ENABLED) SHARE DEFSOPT(SHARED) DEFPSIST(YES)
AMQ8006: WebSphere MQ queue created.
end
2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
For example, to run the commands in the create_qlocal.txt text fle, we would type:
$ runmqsc QMA < create_qlocal.txt
We can see the Dead Letter Queue name specifed on the CRTMQM command.
We can see that the value has been changed from the default value of 10,000 to the value we
specifed in the command.
Summary
In this article, we introduced you to WebSphere MQ in terms of how it is used in Q
replication to achieve assured delivery of messages once and only once. We covered the MQ
queues required for the various scenarios, and gave some guidelines on naming standards. We
then went on to cover the MQ commands that we would usually come across, such as
creating, starting, and stopping a Queue Manager and issuing commands to a Queue Manager.
In the next article, MQ Listener, Channel and Queue Management, we will take a look at how
we manage the WebSphere MQ Listeners, channels and queues.