Due to a known issue do not use JDK1.8.0_151 with WSO2 products. Use JDK 1.8.0_144 until JDK 1.8.0_162-ea is released.
This documentation is for WSO2 Message Broker version 3.2.0. For the latest documentation, see the documentation for WSO2 Enterprise Integrator.

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


If the specified timeToLive value is 0, the message never expires. When a message is published to the broker, the message expiration time is calculated by adding the TTL value sent by the publisher to the current time. Messages that are not delivered before the specified expiration time are deleted. The destruction of obsolete messages conserves storage and computing resources. See the section below on deleting expired messages to understand how the deletion process works.



See Setting Message Expiration for a sample demonstration of this functionality.

Setting the expiration time for messages

The TTL value for messages can be specified by the publisher in two ways:

  • Setting a default expiration time for all messages

    You can use the setTimeToLive method of the MessageProducer interface to set a default expiration time for all messages sent by that producer as shown below. 

    Code Block
    MessageProducer messageProducer = session.createProducer(requestDestination);
    //time to live value in milliseconds
  • Setting an expiration time for a specific message

    You can use the long form of the send or the publish method to set an expiration time for a specific message. The fourth argument sets the expiration time in milliseconds. In the following example, the TTL value of a message is set to 10 seconds: 

    Code Block
    QueuePublisher.publish(message, DeliveryMode.NON_PERSISTENT, 3, 10000);

Deleting expired messages

Messages will not be delivered to consumers after the TTL expires. These expired messages will be deleted in batches periodically. The following values set in the broker.xml (stored in the <MB_HOME>/repository/conf directory) file controls the process of deleting expired messages.