Where are shared queue messages held?
Each message on a shared queue is represented by an entry in a z/OS® coupling facility list structure. If the message data is too large to fit in the same entry, it is offloaded either to a shared message data set (SMDS) or to Db2®.
If the CF structure has been configured to use System Class Memory (SCM), IBM MQ can use this with no additional configuration. See IBM MQ V8 Features and Enhancements, Chapter 8.
Shared queue message storage
Messages that are put onto shared queues are not stored on page sets and do not use buffer pools.
The messages in shared queues have entries on list structures in the z/OS coupling facility (CF). Many queue managers in the same sysplex can access those messages using the CF list structure.
The message data for small shared queue messages is normally included in the coupling facility entry. For larger messages, the message data can be stored either in a shared message data set (SMDS), or as one or more binary large objects (BLOBs) in a Db2 table which is shared by a Db2 data sharing group. Message data exceeding 63 KB is always offloaded to SMDS or Db2. Smaller messages can also optionally be offloaded in the same way to save space in the coupling facility structure. See Specifying offload options for shared messages for more details.
Messages put on a shared queue are referenced in a coupling facility structure until they are retrieved by an MQGET. Coupling facility operations are used to:- Search for the next retrievable message
- Lock uncommitted messages on shared queues
- Notify interested queue managers about the arrival of committed messages
MQPUT and MQGET operations on persistent messages are recorded on the log of the queue manager performing that operation. This minimizes the risk of data loss in the event of a coupling facility failure.
The coupling facility
The messages held on shared queues are referenced inside a coupling facility. The coupling facility lies outside any of the z/OS images in the sysplex and is typically configured to run on a different power supply. The coupling facility is therefore resilient to software failures and we can configure it so that it is resilient to hardware failures or power-outages. This means that messages stored in the coupling facility are highly available.
Each coupling facility list structure used by IBM MQ is dedicated to a specific queue sharing group, but a coupling facility can hold structures for more than one queue sharing group. Queue managers in different queue sharing groups cannot share data. Up to 32 queue managers in a queue sharing group can connect to a coupling facility list structure at the same time.
A single coupling facility list structure can contain up to 512 shared queues. The total amount of message data stored in the structure is limited by the structure capacity. However, with CFLEVEL(5) we can use the offload parameters to offload data for messages less than 63 KB thereby increasing the number of messages which can be stored in the structure, although each message still requires at least a coupling facility entry plus at least 512 bytes of data.
The size of the list structure is restricted by the following factors:- It must lie within a single coupling facility.
- It might share the available coupling facility storage with other structures for IBM MQ and other products.
Coupling facility list structures can have storage class memory associated with them. In certain situations this storage class memory can be useful when used with shared queues. See Use of storage class memory with shared queues for more information.
Plan the CF structure size
If you require guidance on the sizing of your CF structures we can use the MP16: IBM MQ for z/OS Capacity planning and tuning supportpac. We can also use the web-based tool CFSizer, which is provided by IBM to assist with CF sizes.The CF structure object
The queue manager's use of a coupling facility structure is specified in a CF structure (CFSTRUCT) IBM MQ object.
These structure objects are stored in Db2.
When using z/OS commands or definitions relating to a coupling facility structure, the first four characters of the name of the queue sharing group are required. However, an IBM MQ CFSTRUCT object always exists within a single queue sharing group, and so its name does not include the first four characters of the name of the queue sharing group. For example, CFSTRUCT(MYDATA) defined in queue sharing group starting with SQ03 would use coupling facility list structure SQ03MYDATA.
CF structures have a CFLEVEL attribute that determines their functional capability:- 1, 2 - can be used for nonpersistent messages less than 63 KB
- 3 - can be used for persistent and nonpersistent messages less than 63 KB
- 4 - can be used for persistent and nonpersistent messages up to 100 MB
- 5 - can be used for persistent and nonpersistent messages up to 100 MB and selectively offloaded to shared message data sets (SMDS) or Db2.
Backup and recovery of the coupling facility
We can back up coupling facility list structures using the IBM MQ command BACKUP CFSTRUCT. This puts a copy of the persistent messages currently within the CF structure onto the active log data set of the queue manager making the backup, and writes a record of the backup to Db2.
If coupling facility fails, we can use the IBM MQ command RECOVER CFSTRUCT. This uses the backup record from Db2 to locate and restore persistent messages from the backup of the CF structure. Any activity since the last backup is replayed using the logs of all the queue managers in the queue sharing group, and the CF structure is then restored up to the point before the failure.
See the BACKUP CFSTRUCT and RECOVER CFSTRUCT commands for more details.