IBM MQ messages
An IBM MQ message consists of message properties and application data. The message queuing message descriptor (MQMD) contains the control information that accompanies the application data when a message travels between the sending and receiving applications.
Parts of a message
IBM MQ messages consist of two parts:- Message properties
- Application data
Figure 1 represents a message and shows how it is logically divided into message properties and application data.
The application data that is carried in an IBM MQ message is not changed by a queue manager unless data conversion is carried out on it. Also, IBM MQ does not put any restrictions on the content of this data. The length of the data in each message cannot exceed the value of the MaxMsgLength attribute of both the queue and queue manager.
On UNIX, Linux, and Windows, the MaxMsgLength attribute of the queue manager and the queue defaults to 4 MB (4 194 304 bytes) which we can change up to a maximum of 100 MB (104 857 600 bytes) if required.
On IBM i, the MaxMsgLength attribute of the queue manager and the queue defaults to 4 MB (4 194 304 bytes) which we can change up to a maximum of 100 MB (104 857 600 bytes) if required. If we are intending to use IBM MQ messages greater than 15 MB on IBM i, see Building your procedural application on IBM i.
On z/OS, the MaxMsgLength attribute of the queue manager is fixed at 100 MB and the MaxMsgLength attribute of the queue defaults to 4 MB (4 194 304 bytes) which we can change up to a maximum of 100 MB if required.
Make your messages slightly shorter than the value of the MaxMsgLength attribute in some circumstances. For more information, see The data in your message.
You create a message when we use the MQPUT or MQPUT1 MQI calls. As input to these calls, you supply the control information (such as the priority of the message and the name of a reply queue) and your data, and the call then puts the message on a queue. See MQPUT and MQPUT1 for more information about these calls.
Message descriptor
We can access message control information by using the MQMD structure, which defines the message descriptor.
For a full description of the MQMD structure, see MQMD - Message descriptor.
For a description of how to use the fields within the MQMD that contain information about the origin of the message, see Message context.
There are different versions of the message descriptor. Additional information for grouping and segmenting messages (see Message groups) is provided in Version 2 of the message descriptor (or the MQMDE). This is the same as the Version 1 message descriptor but has extra fields. These fields are described in the MQMDE - Message descriptor extension.
- Types of message
There are four types of messages defined by IBM MQ. - Format of message control information and message data
The queue manager is only interested in the format of the control information within a message, whereas applications that handle the message are interested in the format of both the control information and the data. - Message priorities
We can either set the priority of message to a numeric value, or let the message take the default priority of the queue. - Message properties
Use message properties to allow an application to select messages to process, or to retrieve information about a message without accessing MQMD or MQRFH2 headers. They also facilitate communication between IBM MQ and JMS applications. - Selecting messages from queues
We can select messages from queues using the MsgId and CorrelId fields on an MQGET call, or by using a SelectionString on an MQOPEN or MQSUB call. - Asynchronous consumption of IBM MQ messages
Asynchronous consumption uses a set of Message Queue Interface (MQI) extensions, the MQI calls MQCB and MQCTL, which allow an MQI application to be written to consume messages from a set of queues. Messages are delivered to the application by invoking a 'unit of code', identified by the application passing either the message, or a token representing the message. - Message groups
Messages can occur within groups to allow ordering of messages. - Message persistence
Persistent messages are written to logs and queue data files. If a queue manager is restarted after a failure, it recovers these persistent messages as necessary from the logged data. Messages that are not persistent are discarded if a queue manager stops, whether the stoppage is as a result of an operator command or because of the failure of some part of our system. - Messages that fail to be delivered
When a queue manager cannot put a message on a queue, you have various options. - Messages that are backed out
- Reply-to queue and queue manager
- Message context
Message context information allows the application that retrieves the message to find out about the originator of the message.
Parent topic: Application development concepts