This blog will describe the different approaches that can be used to set the message persistence and explain which approach overrules the other ones. Here is a brief summary in case you do not know what message persistence is exactly.

Essentially, if a queue manager is restarted after a failure or as a result of an operation command, the persistent messages stays on the queue whereas non-persistence messages get discarded when the queue manager stops.

There are several ways you can set the message persistence from JMS applications.

The first way is by using the JMS Destination property PERSISTENCE. This can be set on the Destination definition in JNDI, or by using the setPersistence() method on the MQDestination object if you are creating the Destination programmatically.

The default value of the property is APP. This means that when messages are sent to the JMS Destination, the value of the DeliveryMode property is used to determine the message persistence. By default, the DeliveryMode property is set to the value PERSISTENT and it can be changed using the setDeliveryMode() method on MessageProducer object.

If the JMS Destination property PERSISTENCE is set to QDEF, then the message persistence is determined by the definition of the MQ queue that you are putting the message on. To set the persistence of the queue definition, use the MQSC DEFINE or ALTER commands to change the value of the DEFPSIST attribute, specifying either YES (for persistence messages) or NO (for non-persistent messages).

If the JMS Destination property is set to PERS, then all messages sent to that destination will be persistent.

If the JMS Destination property is set to NON, then all messages sent to the destination will be non-persistent.

Related links:

Leave a Reply