IBM Websphere MQ - Working with local queues - Middleware News
Browsing queues
=============
WebSphere® MQ provides a sample queue browser that you can use to look at the contents of the messages on a queue. The browser is supplied in both source and executable formats.
In WebSphere MQ for Windows®, the default file names and paths are:
Source
c:\Program Files\IBM\WebSphere MQ\tools\c\samples\
Executable
c:\Program files\IBM\WebSphere MQ\tools\c\samples\bin\amqsbcg.exe
In WebSphere MQ for UNIX®, the default file names and paths are:
Source
/opt/mqm/samp/amqsbcg0.c (/usr/mqm/samp/amqsbcg0.c on AIX®)
Executable
/opt/mqm/samp/bin/amqsbcg (/usr/mqm/samp/bin/amqsbcg on AIX)
The sample requires two input parameters, the queue name and the queue manager name. For example:
amqsbcg SYSTEM.ADMIN.QMGREVENT.tpp01 saturn.queue.manager
Typical results from this command are shown in Figure 1.
Figure 1. Typical results from queue browser
AMQSBCG0 - starts here
**********************
MQOPEN - 'SYSTEM.ADMIN.QMGR.EVENT'
MQGET of message number 1
****Message descriptor****
StrucId : 'MD ' Version : 2
Report : 0 MsgType : 8
Expiry : -1 Feedback : 0
Encoding : 546 CodedCharSetId : 850
Format : 'MQEVENT '
Priority : 0 Persistence : 0
MsgId : X'414D512073617475726E2E71756575650005D30033563DB8'
CorrelId : X'000000000000000000000000000000000000000000000000'
BackoutCount : 0
ReplyToQ : ' '
ReplyToQMgr : 'saturn.queue.manager '
** Identity Context
UserIdentifier : ' '
AccountingToken :
X'0000000000000000000000000000000000000000000000000000000000000000'
ApplIdentityData : ' '
** Origin Context
PutApplType : '7'
PutApplName : 'saturn.queue.manager '
PutDate : '19970417' PutTime : '15115208'
ApplOriginData : ' '
GroupId : X'000000000000000000000000000000000000000000000000'
MsgSeqNumber : '1'
Offset : '0'
MsgFlags : '0'
OriginalLength : '104'
**** Message ****
length - 104 bytes
00000000: 0700 0000 2400 0000 0100 0000 2C00 0000 '....→.......,...'
00000010: 0100 0000 0100 0000 0100 0000 AE08 0000 '................'
00000020: 0100 0000 0400 0000 4400 0000 DF07 0000 '........D.......'
00000030: 0000 0000 3000 0000 7361 7475 726E 2E71 '....0...saturn.q'
00000040: 7565 7565 2E6D 616E 6167 6572 2020 2020 'ueue.manager '
00000050: 2020 2020 2020 2020 2020 2020 2020 2020 ' '
00000060: 2020 2020 2020 2020 ' '
No more messages
MQCLOSE
MQDISC
Displaying default object attributes
=============================
When you define a WebSphere® MQ object, it takes any attributes that you do not specify from the default object. For example, when you define a local queue, the queue inherits any attributes that you omit in the definition from the default local queue, which is called SYSTEM.DEFAULT.LOCAL.QUEUE. To see exactly what these attributes are, use the following command:
DISPLAY QUEUE (SYSTEM.DEFAULT.LOCAL.QUEUE)
The syntax of this command is different from that of the corresponding DEFINE command. On the DISPLAY command you can give just the queue name, whereas on the DEFINE command you have to specify the type of the queue, that is, QLOCAL, QALIAS, QMODEL, or QREMOTE.
You can selectively display attributes by specifying them individually. For example:
DISPLAY QUEUE (ORANGE.LOCAL.QUEUE) +
MAXDEPTH +
MAXMSGL +
CURDEPTH;
This command displays the three specified attributes as follows:
AMQ8409: Display Queue details.
QUEUE(ORANGE.LOCAL.QUEUE) TYPE(QLOCAL)
CURDEPTH(0) MAXDEPTH(5000)
MAXMSGL(4194304)
CURDEPTH is the current queue depth, that is, the number of messages on the queue. This is a useful attribute to display, because by monitoring the queue depth you can ensure that the queue does not become full.
Copying a local queue definition
===========================
You can copy a queue definition using the LIKE attribute on the DEFINE command. For example:
DEFINE QLOCAL (MAGENTA.QUEUE) +
LIKE (ORANGE.LOCAL.QUEUE)
This command creates a queue with the same attributes as our original queue ORANGE.LOCAL.QUEUE, rather than those of the system default local queue. Enter the name of the queue to be copied exactly as it was entered when you created the queue. If the name contains lower case characters, enclose the name in single quotation marks.
You can also use this form of the DEFINE command to copy a queue definition, but substitute one or more changes to the attributes of the original. For example:
DEFINE QLOCAL (THIRD.QUEUE) +
LIKE (ORANGE.LOCAL.QUEUE) +
MAXMSGL(1024);
This command copies the attributes of the queue ORANGE.LOCAL.QUEUE to the queue THIRD.QUEUE, but specifies that the maximum message length on the new queue is to be 1024 bytes, rather than 4194304.
Note:
1. When you use the LIKE attribute on a DEFINE command, you are copying the queue attributes only. You are not copying the messages on the queue.
2. If you a define a local queue, without specifying LIKE, it is the same as DEFINE LIKE(SYSTEM.DEFAULT.LOCAL.QUEUE).
Changing local queue attributes
========================
You can change queue attributes in two ways, using either the ALTER QLOCAL command or the DEFINE QLOCAL command with the REPLACE attribute. In Defining a local queue, we defined the queue called ORANGE.LOCAL.QUEUE. Suppose, for example, you want to decrease the maximum message length on this queue to 10 000 bytes.
* Using the ALTER command:
ALTER QLOCAL (ORANGE.LOCAL.QUEUE) MAXMSGL(10000)
This command changes a single attribute, that of the maximum message length; all the other attributes remain the same.
* Using the DEFINE command with the REPLACE option, for example:
DEFINE QLOCAL (ORANGE.LOCAL.QUEUE) MAXMSGL(10000) REPLACE
This command changes not only the maximum message length, but also all the other attributes, which are given their default values. The queue is now put enabled whereas previously it was put inhibited. Put enabled is the default, as specified by the queue SYSTEM.DEFAULT.LOCAL.QUEUE.
If you decrease the maximum message length on an existing queue, existing messages are not affected. Any new messages, however, must meet the new criteria.
Clearing a local queue
=================
To delete all the messages from a local queue called MAGENTA.QUEUE, use the following command:
CLEAR QLOCAL (MAGENTA.QUEUE)
Note: There is no prompt that enables you to change your mind; once you press the Enter key the messages are lost.
You cannot clear a queue if:
* There are uncommitted messages that have been put on the queue under sync point.
* An application currently has the queue open.
Deleting a local queue
=================
Use the MQSC command DELETE QLOCAL to delete a local queue. A queue cannot be deleted if it has uncommitted messages on it. However, if the queue has one or more committed messages and no uncommitted messages, it can be deleted only if you specify the PURGE option. For example:
DELETE QLOCAL (PINK.QUEUE) PURGE
Specifying NOPURGE instead of PURGE ensures that the queue is not deleted if it contains any committed messages.
Enabling large queues
=================
WebSphere® MQ supports queues larger than 2 GB. On Windows® systems, support for large files is available without any additional enablement. On AIX®, HP-UX, Linux®, and Solaris systems, you need to explicitly enable large file support before you can create queue files larger than 2 GB. See your operating system documentation for information on how to do this.
Some utilities, such as tar, cannot cope with files greater than 2 GB. Before enabling large file support, check your operating system documentation for information on restrictions on utilities you use.
Browsing queues
=============
WebSphere® MQ provides a sample queue browser that you can use to look at the contents of the messages on a queue. The browser is supplied in both source and executable formats.
In WebSphere MQ for Windows®, the default file names and paths are:
Source
c:\Program Files\IBM\WebSphere MQ\tools\c\samples\
Executable
c:\Program files\IBM\WebSphere MQ\tools\c\samples\bin\amqsbcg.exe
In WebSphere MQ for UNIX®, the default file names and paths are:
Source
/opt/mqm/samp/amqsbcg0.c (/usr/mqm/samp/amqsbcg0.c on AIX®)
Executable
/opt/mqm/samp/bin/amqsbcg (/usr/mqm/samp/bin/amqsbcg on AIX)
The sample requires two input parameters, the queue name and the queue manager name. For example:
amqsbcg SYSTEM.ADMIN.QMGREVENT.tpp01 saturn.queue.manager
Typical results from this command are shown in Figure 1.
Figure 1. Typical results from queue browser
AMQSBCG0 - starts here
**********************
MQOPEN - 'SYSTEM.ADMIN.QMGR.EVENT'
MQGET of message number 1
****Message descriptor****
StrucId : 'MD ' Version : 2
Report : 0 MsgType : 8
Expiry : -1 Feedback : 0
Encoding : 546 CodedCharSetId : 850
Format : 'MQEVENT '
Priority : 0 Persistence : 0
MsgId : X'414D512073617475726E2E71756575650005D30033563DB8'
CorrelId : X'000000000000000000000000000000000000000000000000'
BackoutCount : 0
ReplyToQ : ' '
ReplyToQMgr : 'saturn.queue.manager '
** Identity Context
UserIdentifier : ' '
AccountingToken :
X'0000000000000000000000000000000000000000000000000000000000000000'
ApplIdentityData : ' '
** Origin Context
PutApplType : '7'
PutApplName : 'saturn.queue.manager '
PutDate : '19970417' PutTime : '15115208'
ApplOriginData : ' '
GroupId : X'000000000000000000000000000000000000000000000000'
MsgSeqNumber : '1'
Offset : '0'
MsgFlags : '0'
OriginalLength : '104'
**** Message ****
length - 104 bytes
00000000: 0700 0000 2400 0000 0100 0000 2C00 0000 '....→.......,...'
00000010: 0100 0000 0100 0000 0100 0000 AE08 0000 '................'
00000020: 0100 0000 0400 0000 4400 0000 DF07 0000 '........D.......'
00000030: 0000 0000 3000 0000 7361 7475 726E 2E71 '....0...saturn.q'
00000040: 7565 7565 2E6D 616E 6167 6572 2020 2020 'ueue.manager '
00000050: 2020 2020 2020 2020 2020 2020 2020 2020 ' '
00000060: 2020 2020 2020 2020 ' '
No more messages
MQCLOSE
MQDISC
Displaying default object attributes
=============================
When you define a WebSphere® MQ object, it takes any attributes that you do not specify from the default object. For example, when you define a local queue, the queue inherits any attributes that you omit in the definition from the default local queue, which is called SYSTEM.DEFAULT.LOCAL.QUEUE. To see exactly what these attributes are, use the following command:
DISPLAY QUEUE (SYSTEM.DEFAULT.LOCAL.QUEUE)
The syntax of this command is different from that of the corresponding DEFINE command. On the DISPLAY command you can give just the queue name, whereas on the DEFINE command you have to specify the type of the queue, that is, QLOCAL, QALIAS, QMODEL, or QREMOTE.
You can selectively display attributes by specifying them individually. For example:
DISPLAY QUEUE (ORANGE.LOCAL.QUEUE) +
MAXDEPTH +
MAXMSGL +
CURDEPTH;
This command displays the three specified attributes as follows:
AMQ8409: Display Queue details.
QUEUE(ORANGE.LOCAL.QUEUE) TYPE(QLOCAL)
CURDEPTH(0) MAXDEPTH(5000)
MAXMSGL(4194304)
CURDEPTH is the current queue depth, that is, the number of messages on the queue. This is a useful attribute to display, because by monitoring the queue depth you can ensure that the queue does not become full.
Copying a local queue definition
===========================
You can copy a queue definition using the LIKE attribute on the DEFINE command. For example:
DEFINE QLOCAL (MAGENTA.QUEUE) +
LIKE (ORANGE.LOCAL.QUEUE)
This command creates a queue with the same attributes as our original queue ORANGE.LOCAL.QUEUE, rather than those of the system default local queue. Enter the name of the queue to be copied exactly as it was entered when you created the queue. If the name contains lower case characters, enclose the name in single quotation marks.
You can also use this form of the DEFINE command to copy a queue definition, but substitute one or more changes to the attributes of the original. For example:
DEFINE QLOCAL (THIRD.QUEUE) +
LIKE (ORANGE.LOCAL.QUEUE) +
MAXMSGL(1024);
This command copies the attributes of the queue ORANGE.LOCAL.QUEUE to the queue THIRD.QUEUE, but specifies that the maximum message length on the new queue is to be 1024 bytes, rather than 4194304.
Note:
1. When you use the LIKE attribute on a DEFINE command, you are copying the queue attributes only. You are not copying the messages on the queue.
2. If you a define a local queue, without specifying LIKE, it is the same as DEFINE LIKE(SYSTEM.DEFAULT.LOCAL.QUEUE).
Changing local queue attributes
========================
You can change queue attributes in two ways, using either the ALTER QLOCAL command or the DEFINE QLOCAL command with the REPLACE attribute. In Defining a local queue, we defined the queue called ORANGE.LOCAL.QUEUE. Suppose, for example, you want to decrease the maximum message length on this queue to 10 000 bytes.
* Using the ALTER command:
ALTER QLOCAL (ORANGE.LOCAL.QUEUE) MAXMSGL(10000)
This command changes a single attribute, that of the maximum message length; all the other attributes remain the same.
* Using the DEFINE command with the REPLACE option, for example:
DEFINE QLOCAL (ORANGE.LOCAL.QUEUE) MAXMSGL(10000) REPLACE
This command changes not only the maximum message length, but also all the other attributes, which are given their default values. The queue is now put enabled whereas previously it was put inhibited. Put enabled is the default, as specified by the queue SYSTEM.DEFAULT.LOCAL.QUEUE.
If you decrease the maximum message length on an existing queue, existing messages are not affected. Any new messages, however, must meet the new criteria.
Clearing a local queue
=================
To delete all the messages from a local queue called MAGENTA.QUEUE, use the following command:
CLEAR QLOCAL (MAGENTA.QUEUE)
Note: There is no prompt that enables you to change your mind; once you press the Enter key the messages are lost.
You cannot clear a queue if:
* There are uncommitted messages that have been put on the queue under sync point.
* An application currently has the queue open.
Deleting a local queue
=================
Use the MQSC command DELETE QLOCAL to delete a local queue. A queue cannot be deleted if it has uncommitted messages on it. However, if the queue has one or more committed messages and no uncommitted messages, it can be deleted only if you specify the PURGE option. For example:
DELETE QLOCAL (PINK.QUEUE) PURGE
Specifying NOPURGE instead of PURGE ensures that the queue is not deleted if it contains any committed messages.
Enabling large queues
=================
WebSphere® MQ supports queues larger than 2 GB. On Windows® systems, support for large files is available without any additional enablement. On AIX®, HP-UX, Linux®, and Solaris systems, you need to explicitly enable large file support before you can create queue files larger than 2 GB. See your operating system documentation for information on how to do this.
Some utilities, such as tar, cannot cope with files greater than 2 GB. Before enabling large file support, check your operating system documentation for information on restrictions on utilities you use.
Comments
Post a Comment