[MQ 9.4.0 Jun 2024]

Removing acknowledged AMQP messages from the queue in batches

If an AMQP application is using QOS_AT_LEAST_ONCE(1) message delivery, the AMQP service waits for an acknowledgment from the application before it discards the copy of a message that it keeps after it sends that message to the application. From IBM® MQ 9.3.3, messages that have been acknowledged are removed from the queue in batches, instead of individually, resulting in improved performance.

About this task

Before IBM MQ 9.4.0, each message is removed from the queue individually.

From IBM MQ 9.4.0, you can use the two system properties com.ibm.mq.AMQP.BATCHSZ and com.ibm.mq.AMQP.BATCHINT to fine tune the processing of acknowledgments in batches for improved performance:
com.ibm.mq.AMQP.BATCHSZ
This attribute defines the maximum number of acknowledgments to be received before the AMQP service removes messages. The number can be in the range 1 through 9999. If an invalid number is set, or if the specified number is out of range, the default value of 50 is used.
The batch size does not affect the way that the messages are transferred. Messages are always transferred individually, but are then removed in a batch after the AMQP service receives the acknowledgments. The actual size of a batch can be less than the value specified by com.ibm.mq.AMQP.BATCHINT. For example, a batch completes if the period set by the com.ibm.mq.AMQP.BATCHINT attribute expires.
com.ibm.mq.AMQP.BATCHINT
This attribute defines the amount of time, in milliseconds, for which the AMQP service keeps acknowledged messages on the queue. If the batch is not full, then the batch is cleared after this duration. You can specify any number of milliseconds, from 1 through 999 999 999. The default value is 50. If you do not specify a value for this attribute, the default value of 50 is used.
Notes:
  1. Whether the AMQP service waits for an acknowledgment before it discards a message depends on which of the following two qualities of service an application is using for message delivery:
    • QOS for QOS_AT_MOST_ONCE(0)

      If an AMQP application is using this quality of service, it does not acknowledge messages, so the AMQP service discards messages after it sends them to the application without waiting for an acknowledgment.

    • QOS_AT_LEAST_ONCE(1)

      If an AMQP application is using this quality of service, it does acknowledge messages, so the AMQP service keeps a copy of each message after it sends it to the application until it receives an acknowledgment from the application. If the application disconnects from or loses the connection before acknowledging the message, the message is made available to other applications. The AMQP service does not remove a message from the queue until it has been acknowledged.

  2. [MQ Appliance]The com.ibm.mq.AMQP.BATCHSZ and com.ibm.mq.AMQP.BATCHINT system properties are not applicable on IBM MQ Appliance. A default value of 50 is used on IBM MQ Appliance.
.

Procedure

Use the com.ibm.mq.AMQP.BATCHSZ and com.ibm.mq.AMQP.BATCHINT system properties to fine tune the processing of acknowledgments in batches.
From IBM MQ 9.3.3, when the queue manager is created, the amqp_java.properties file contains the following default values for the system properties:
-Dcom.ibm.mq.AMQP.BATCHSIZE=50
-Dcom.ibm.mq.AMQP.BATCHINT=50

Depending on the message rate consumed, you can fine tune processing of acknowledgments in batches for improved performance. A migrated queue manager does not have these properties in the amqp_java.properties file. So, for a migrated queue manager, or if the properties are not set, the default values are used. You can add these properties to fine tune the values for optimized performance.

Acknowledged messages are removed in batches when one of the following conditions is met:
  • The number of acknowledged messages reaches com.ibm.mq.AMQP.BATCHSZ.
  • com.ibm.mq.AMQP.BATCHINT is exceeded after the start of the batch.
  • The application disconnects or closes the queue or topic before the two previous conditions are satisfied.