+

Search Tips | Advanced Search

Messages and queues

Messages and queues are the basic components of a message queuing system.


What is a message?

A message is a string of bytes that is meaningful to the applications that use it. Messages are used to transfer information from one application program to another (or between different parts of the same application). The applications can be running on the same platform, or on different platforms.

An IBM MQ message is made up of:

  • The application data. The content and structure of the application data is defined by the application programs that use it.
  • A message descriptor. The message descriptor identifies the message and contains additional control information, such as the type of message and the priority assigned to the message by the sending application.

    The format of the message descriptor is defined by IBM MQ. For a complete description of the message descriptor, see MQMD - Message descriptor.

  • Message properties. Meta-data about the message. The content of the message properties are defined by the application programs that use them. For more information, see Message properties.


Message lengths

The default maximum message length is 4 MB, although we can increase this to a maximum length of 100 MB (where 1 MB equals 1 048 576 bytes). In practice, the message length might be limited by:

  • The maximum message length defined for the receiving queue
  • The maximum message length defined for the queue manager
  • The maximum message length defined by the queue
  • The maximum message length defined by either the sending or receiving application
  • The amount of storage available for the message

It might take several messages to send all the information that an application requires.


How do applications send and receive messages?

Application programs send and receive messages using MQI calls.

For example, to put a message onto a queue, an application:
  1. Opens the required queue by issuing an MQI MQOPEN call
  2. Issues an MQI MQPUT call to put the message onto the queue

Another application can retrieve the message from the same queue by issuing an MQI MQGET call

For more information about MQI calls, see MQI calls.


What is a queue?

A queue is a data structure used to store messages.

Each queue is owned by a queue manager. The queue manager is responsible for maintaining the queues it owns, and for storing all the messages it receives onto the appropriate queues. The messages might be put on the queue by application programs, or by a queue manager as part of its normal operation.


Predefined queues and dynamic queues

Queues can be characterized by the way they are created:

  • Predefined queues are created by an administrator using the appropriate MQSC or PCF commands. Predefined queues are permanent; they exist independently of the applications that use them and survive IBM MQ restarts.
  • Dynamic queues are created when an application issues an MQOPEN request specifying the name of a model queue. The queue created is based on a template queue definition, which is called a model queue. We can create a model queue using the MQSC command DEFINE QMODEL. The attributes of a model queue (for example, the maximum number of messages that can be stored on it) are inherited by any dynamic queue that is created from it.

    Model queues have an attribute that specifies whether the dynamic queue is to be permanent or temporary. Permanent queues survive application and queue manager restarts; temporary queues are lost on restart.


Retrieving messages from queues

Suitably authorized applications can retrieve messages from a queue according to the following retrieval algorithms:

  • First-in-first-out (FIFO).
  • Message priority, as defined in the message descriptor. Messages that have the same priority are retrieved on a FIFO basis.
  • A program request for a specific message.

The MQGET request from the application determines the method used.

Parent topic: Introduction to message queuing

Last updated: 2020-10-04