Question & Answer
This is intended to answer frequently asked questions regarding WebSphere MQ handling of persistent and nonpersistent messages. Q1. Why do messages get discarded at restart? Q2. Why do messages survive a restart? Q3. What is the best way to be certain that messages are persistent? Q4. If you send nonpersistent message over a fast channel and the channel fails, can you lose your messages?
A1. Nonpersistent messages do not survive restarts because they are considered to be nonessential messages. However the queue attribute NPMCLASS(HIGH) can change the treatment of non-persistent messages (see details below).
A2. Persistent messages survive system restarts because they are considered to be essential messages. If the data in a message is important to your business, then you should always make your messages persistent.
A3. Set MQMD message persistence to persistent (MQPER_PERSISTENT), or nonpersistent (MQPER_NOT_PERSISTENT) and your message will always retain that value.
Note: MQPER_PERSISTENCE_AS_Q_DEF is the default setting for the persistence value in the MQMD. See the persistence values listed below.
A4. Yes, you can lose nonpersistent messages on a fast channel because they are not logged.
Effect of message persistence
- Persistent messages are logged. Logging messages reduces the performance of your application, so you should use persistent messages for essential data only.
- If the data in a message can be discarded when a queue manager stops or fails, use a nonpersistent message.
MQPER_* (Persistence Values)
Diagnostic hints and tips:
- If you suspect that you are losing messages, or if you want to verify the persistence setting for your application's messages. Trace your application putting a message to the destination queue, or browse messages on the queue.
- Examine the MQMD - Message descriptor fields and verify the persistence setting.
- The queue attribute NPMCLASS(HIGH) can change the treatment of non-persistent messages on a 'normal' queue manager restart. The queue manager attempts to retain non-persistent messages on this queue over a queue manager restart. Note that you cannot set this parameter on z/OS.
MQPER_PERSISTENCE_AS_Q_DEF can lead to unexpected results. If there is more than one definition in the queue-name resolution path, the default persistence attribute is taken from first queue definition in the path at the time of the MQPUT or MQPUT1 call. This queue could be an:
- alias queue
- local queue
- local definition of a remote queue
- queue-manager alias
- transmission queue
- cluster queue
15 June 2018