Using read ahead in a client application

You can use read ahead on a client to allow non persistent messages to be sent to a client without the client application having to request the messages.

When a client requires a message from a server, it sends a request to the server. It sends a separate request for each of the messages it consumes. To improve the performance of a client consuming non persistent messages by avoiding having to send these request messages, a client can be configured to use read ahead. Read ahead allows messages to be sent to a client without an application having to request them.

Using read ahead can improve performance when consuming non persistent messages from a client application. This performance improvement is available to both MQI and JMS applications. Client applications using MQGET or asynchronous consumption benefit from the performance improvements when consuming non persistent messages.

When you call MQOPEN with MQOO_READ_AHEAD, the IBM® MQ client only enables read-ahead if certain conditions are met. These conditions include:
  • Both the client and remote queue manager must be at IBM WebSphere® MQ 7.0 or later.
  • The client application must be compiled and linked against the threaded IBM MQ MQI client libraries.
  • The client channel must be using TCP/IP protocol
  • The channel must have a non-zero SharingConversations (SHARECNV) setting in both the client and server channel definitions.

When read ahead is enabled, messages are sent to a memory buffer on the client called the read ahead buffer. The client has a read ahead buffer for each queue it has open with read ahead enabled. The messages in the read ahead buffer are not persisted. The client periodically updates the server with information about the amount of data it has consumed.

Not all client application designs are suited to using read ahead because not all options are supported for use. Some options are required to be consistent between MQGET calls when read ahead is enabled. If a client alters its selection criteria between MQGET calls, messages being stored in the read ahead buffer remain stranded in the client read ahead buffer. For more information, see Improving performance of non-persistent messages

Read ahead configuration is controlled by three attributes, MaximumSize, PurgeTime, and UpdatePercentage, which are specified in the MessageBuffer stanza of the IBM MQ client configuration file.