Consumer cleanup utility for the publish/subscribe domain

 

To avoid the problems associated with message consumer objects in the publish/subscribe domain not closing gracefully, WebSphere MQ JMS supplies a consumer cleanup utility that attempts to clean up the resources associated with a consumer that has failed. This utility runs in the background and does not affect other WebSphere MQ JMS operations. If the utility detects a large number of problems associated with a given queue manager, you might see some performance degradation while resources are being cleaned up.

Whenever possible, close all message consumer objects gracefully to avoid an accumulation of these types of problems.

If applications use the domain independent classes, the cleanup utility is invoked only if the applications perform publish/subscribe operations, such as creating a Topic object, or creating a MessageConsumer object with a Topic object retrieved from a JNDI namespace. This is to prevent the cleanup utility from being invoked in an environment in which applications are performing only point-to-point operations.

The exact behavior of the cleanup utility depends on where the subscription store is located:

Queue based subscription store

For a queue based subscription store, the cleanup utility runs against a queue manager when the first Connection object to use that queue manager initializes. If all the Connection objects that use a given queue manager close, the utility runs again only when the next Connection object to use that queue manager initializes.

The cleanup utility uses the information in the queues, SYSTEM.JMS.ADMIN.QUEUE and SYSTEM.JMS.PS.STATUS.QUEUE, to detect nondurable message consumers that have failed previously. If it finds a failed consumer, the utility cleans up the resources associated with the consumer by de-registering the consumer from the broker and deleting its consumer queue, provided it is not a shared queue, and any unconsumed messages on the queue.

Broker based subscription store

For a broker based subscription store, the cleanup utility runs at regular intervals on a background thread while there is at least one Connection object that uses a given queue manager. One cleanup thread is created for each queue manager for which a Connection object exists within the JVM.

The cleanup utility uses information in the queue, SYSTEM.JMS.REPORT.QUEUE (the messages in this queue are typically report messages from the publish/subscribe broker), to perform any necessary cleanup. This might involve deleting consumer queues and unconsumed messages that are no longer required.

Two properties of a ConnectionFactory object control the behavior of the cleanup thread: CLEANUPINT and CLEANUP. CLEANUPINT determines how often, in milliseconds, the cleanup utility is run against any given queue manager. CLEANUP has four possible values:

CLEANUP(SAFE)

This is the default value.

The cleanup thread tries to delete any consumer queues and unconsumed messages that are no longer required. This mode of cleanup does not interfere with the operation of other JMS applications.

CLEANUP(STRONG)

The cleanup thread performs like the CLEANUP(SAFE) option, but it also deletes any messages on the queue, SYSTEM.JMS.REPORT.QUEUE, that it does not recognize.

This mode of cleanup can interfere with the operation of JMS applications running with later versions of WebSphere MQ JMS. If multiple JMS applications are using the same queue manager, but using different versions of WebSphere MQ JMS, only applications using the most recent version of WebSphere MQ JMS must use this option.

CLEANUP(NONE)

In this special mode, no cleanup is performed, and consumer queues and unconsumed messages that are no longer required are not deleted.

This option can be useful if the application and the queue manager are on a different systems, especially if the application only sends messages and does not receive them. At some time, however, cleanup must be initiated to delete consumer queues and unconsumed messages that are no longer required. This can be done by a JMS application that uses a ConnectionFactory object with the property CLEANUP(SAFE) or CLEANUP(STRONG), or by using the manual cleanup utility, which is described in Manual cleanup.

CLEANUP(ASPROP)

The mode of cleanup is determined by the system property com.ibm.mq.jms.cleanup, which is queried when the JVM starts.

This property can be set on the Java™ command line by using the -D option. Its value can be SAFE, STRONG, or NONE. Any other value causes an exception. If the property not set, its value defaults to SAFE.

This option allows you to change the mode of cleanup within an entire JVM without having to update every ConnectionFactory object. This is useful for applications or application servers that use multiple ConnectionFactory objects.

If multiple Connection objects for the same queue manager exist within a JVM, but the Connection objects use different values for the CLEANUPINT and CLEANUP properties, the following rules determine the behavior of the cleanup utility:

  1. If a Connection object using the CLEANUP(NONE) option fails, cleanup does not run. The cleanup thread eventually runs, however, if another Connection object is using the CLEANUP(SAFE) or CLEANUP(STRONG) option.

  2. If any Connection object is using the CLEANUP(STRONG) option, the cleanup thread operates in STRONG mode. Otherwise, if any Connection object is using the CLEANUP(SAFE) option, the cleanup thread operates in SAFE mode. Otherwise, there is no cleanup thread.

  3. The cleanup utility runs at intervals determined by the smallest value of the CLEANUPINT property of those Connections that are using the CLEANUP(SAFE) or CLEANUP(STRONG) option.


uj25220_