JMS persistent messages

 

A WebSphere MQ queue has an attribute called NonPersistentMessageClass. The value of this attribute determines whether nonpersistent messages on the queue are discarded when the queue manager restarts.

We can set the attribute for a local queue by using the WebSphere MQ Script (MQSC) command, DEFINE QLOCAL, with either of the following parameters:

NPMCLASS(NORMAL)

Nonpersistent messages on the queue are discarded when the queue manager restarts. This is the default value.

NPMCLASS(HIGH)

Nonpersistent messages on the queue are not discarded when the queue manager restarts following a quiesced or immediate shutdown. Nonpersistent messages might be discarded, however, following a preemptive shutdown or a failure.
This section describes how WebSphere MQ JMS applications can use this queue attribute to provide better performance for JMS persistent messages.

The PERSISTENCE property of a Queue or Topic object can have the value HIGH. We can use the WebSphere MQ JMS administration tool to set this value, or an application can call the Destination.setPersistence() method passing the value JMSC.MQJMS_PER_HIGH as a parameter.

If an application sends a JMS persistent message or a JMS nonpersistent message to a destination whose PERSISTENCE property has the value HIGH, and the underlying WebSphere MQ queue is set to NPMCLASS(HIGH), the message is put on the queue as a WebSphere MQ nonpersistent message. If the PERSISTENCE property of the destination does not have the value HIGH, or if the underlying queue is set to NPMCLASS(NORMAL), a JMS persistent message is put on the queue as a WebSphere MQ persistent message, and a JMS nonpersistent message is put on the queue as a WebSphere MQ nonpersistent message.

If a JMS persistent message is put on a queue as a WebSphere MQ nonpersistent message, and you want to ensure that the message is not discarded following a quiesced or immediate shutdown of a queue manager, all queues through which the message might be routed must be set to NPMCLASS(HIGH). In the publish/subscribe domain, these queues include subscriber queues. As an aid to enforcing this configuration, the WebSphere MQ JMS client throws an InvalidDestinationException if an application tries to create a message consumer for a destination whose PERSISTENCE property has the value HIGH and the underlying WebSphere MQ queue is set to NPMCLASS(NORMAL).

Set the PERSISTENCE property of a destination to HIGH has no effect on how a message is received from that destination. A message sent as a JMS persistent message is received as a JMS persistent message, and a message sent as a JMS nonpersistent message is received as a JMS nonpersistent message.

When an application sends the first message to a destination whose PERSISTENCE property has the value HIGH, or when an application creates the first message consumer for a destination whose PERSISTENCE property has the value HIGH, the WebSphere MQ JMS client issues an MQINQ call to determine whether NPMCLASS(HIGH) is set on the underlying WebSphere MQ queue. The application must therefore have the authority to inquire on the queue. In addition, the WebSphere MQ JMS client preserves the result of the MQINQ call until the destination is deleted, and does not issue more MQINQ calls. Therefore, if you change the NPMCLASS setting on the underlying queue while the application is still using the destination, the WebSphere MQ JMS client does not notice the new setting.

By allowing JMS persistent messages to be put on WebSphere MQ queues as WebSphere MQ nonpersistent messages, you are gaining performance at the expense of some reliability. If you require maximum reliability for JMS persistent messages, do not send the messages to a destination whose PERSISTENCE property has the value HIGH.


uj25200_