IBM Support

IBM MQ Message persistence FAQs

Question & Answer


Question

This article tries to answer Frequently Asked Questions regarding the handling of persistent and nonpersistent messages in an IBM MQ queue manager:
Q1. Why do messages get discarded at restart of the queue manager?
Q2. Why do messages survive a restart?
Q3. What is the best way to be certain that messages are persistent?
Q4. If you send a non-persistent message over a fast channel and the channel fails, can you lose your messages?

Answer

A1. Non-persistent messages do not survive the restart of a queue manager because they are considered to be non-essential 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. The MQ Client application that puts the message into the queue is RESPONSIBLE for determining if a message is persistent or non-persistent.
The application needs to set in the Message Descriptor (MQMD) the 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.
.
For more details see:

https://www.ibm.com/support/pages/node/6576289
Can a Non-Persistent message be put into an IBM MQ Queue that has attribute DEFPSIST equals to YES?
Or vice versa:
Can a Persistent message be put into an IBM MQ Queue that has attribute DEFPSIST equals to NO?
Answer: The answer to both questions is: YES
Each queue has an attribute that determines the "default persistence" (DEFPSIST) for new  messages that will be stored in the queue.
The attribute is defined at the queue level and it is ONLY A SUGGESTION for the MQ client application that has opened the queue.
The persistence of a message is set by the MQ client application.
Use sample "amqsbcg" to browse the messages:
 The values are:
   Persistence : 0 => Non-Persistent
   Persistence : 1 => Persistent
 

A4. Yes, you can lose non-persistent messages on a fast channel because they are not logged.

Effect of message persistence
  • Persistent messages are logged into disk, which requires additional processing and therefore 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 non-persistent message.


MQPER_* (Persistence Values)
 
MQPER_NOT_PERSISTENT
0
X'00000000'
MQPER_PERSISTENT
1
X'00000001'
MQPER_PERSISTENCE_AS_Q_DEF
2
X'00000002'

Diagnostic hints and tips:

1: 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 message on the queue:
https://www.ibm.com/docs/en/ibm-mq/9.4?topic=queues-browsing-sample-program
IBM MQ / 9.4
Browsing queues with the sample program
 
2: Examine the the MQMD Message Descriptor and verify the persistence setting.
https://www.ibm.com/docs/en/ibm-mq/9.4?topic=constants-mqper-persistence-values
IBM MQ / 9.4
MQPER_* (Persistence Values)
 
3: 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.
4: The following article could be helpful:
https://www.ibm.com/support/pages/node/507119
Where's my message? Tool and instructions to use the MQ recovery log to find out what happened to your persistent MQ messages on distributed platforms

     
 

Additional information

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
+ tags:
Revised by: Angel Rivera; Rich Montjoy;
+++ end +++

[{"Type":"MASTER","Line of Business":{"code":"LOB67","label":"IT Automation \u0026 App Modernization"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSYHRD","label":"IBM MQ"},"ARM Category":[{"code":"a8m50000000ClNeAAK","label":"Messages"}],"ARM Case Number":"TS016968875","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Product Synonym

WMQ MQ

Document Information

Modified date:
29 August 2024

UID

swg21231054