com.ibm.mq.jms
Class Cleanup

java.lang.Object
  |
  +--com.ibm.mq.jms.MQConnectionFactory
        |
        +--com.ibm.mq.jms.Cleanup
All Implemented Interfaces:
javax.jms.ConnectionFactory, javax.naming.Referenceable, java.lang.Runnable, java.io.Serializable

public class Cleanup
extends MQConnectionFactory
implements java.lang.Runnable

Cleanup contains utilities for dealing with nondurable subscriptions which are broken, by using the SUBSTATE(BROKER) option. The class is not applicable if you use a direct connection to a broker.

See Also:
Serialized Form

Field Summary
   
Constructor Summary
Cleanup()
          Default constructor.
Cleanup(MQConnectionFactory mqcf)
          Constructor that imports property values.
 
Method Summary
 void cleanup()
          Runs Cleanup once.
 long getCleanupInterval()
          Gets the cleanup interval.
 int getCleanupLevel()
          Gets the cleanup level.
 javax.jms.ExceptionListener getExceptionListener()
          Gets the ExceptionListener.
 boolean isRunning()
          Indicates whether run() is currently active.
static void main(java.lang.String[] args)
          Invokes the utility directly from a command line.
 void run()
          Runs Cleanup.
 void setCleanupInterval(long interval)
          Sets the cleanup interval.
 void setCleanupLevel(int level)
          Sets the cleanup level.
 void setExceptionListener(javax.jms.ExceptionListener el)
          Sets the ExceptionListener.
 void setPassword(java.lang.String newPassword)
          Sets the durable connection password
 void setUserID(java.lang.String newuserID)
          Sets the durable connection user ID.
 void stop()
          Stops any running cleanup thread.
 
Methods inherited from class com.ibm.mq.jms.MQConnectionFactory
createConnection, createConnection, getBrokerCCSubQueue, getBrokerControlQueue, getBrokerPubQueue, getBrokerQueueManager, getBrokerSubQueue, getBrokerVersion, getCCDTURL, getCCSID, getChannel, getClientId, getClientID, getCloneSupport, getConnTag, getDescription, getDirectAuth, getFailIfQuiesce, getHdrCompList, getHostName, getLocalAddress, getMapNameStyle, getMessageRetention, getMessageSelection, getMQConnectionOptions, getMsgBatchSize, getMsgCompList, getMulticast, getOptimisticPublication, getOutcomeNotification, getPollingInterval, getPort, getProcessDuration, getProxyHostName, getProxyPort, getPubAckInterval, getQueueManager, getReceiveExit, getReceiveExitInit, getReceiveIsolation, getReference, getRescanInterval, getSecurityExit, getSecurityExitInit, getSendExit, getSendExitInit, getSparseSubscriptions, getSSLCertStores, getSSLCertStoresAsString, getSSLCipherSuite, getSSLFipsRequired, getSSLPeerName, getSSLResetCount, getSSLSocketFactory, getStatusRefreshInterval, getSubscriptionStore, getSyncpointAllGets, getTargetClientMatching, getTemporaryModel, getTempQPrefix, getTransportType, getUseConnectionPooling, getVersion, setBrokerCCSubQueue, setBrokerControlQueue, setBrokerPubQueue, setBrokerQueueManager, setBrokerSubQueue, setBrokerVersion, setCCDTURL, setCCSID, setChannel, setClientId, setClientID, setCloneSupport, setConnTag, setDescription, setDirectAuth, setFailIfQuiesce, setHdrCompList, setHostName, setLocalAddress, setMapNameStyle, setMessageRetention, setMessageSelection, setMQConnectionOptions, setMsgBatchSize, setMsgCompList, setMulticast, setOptimisticPublication, setOutcomeNotification, setPollingInterval, setPort, setProcessDuration, setProxyHostName, setProxyPort, setPubAckInterval, setQueueManager, setReceiveExit, setReceiveExitInit, setReceiveIsolation, setRescanInterval, setSecurityExit, setSecurityExitInit, setSendExit, setSendExitInit, setSparseSubscriptions, setSSLCertStores, setSSLCertStores, setSSLCipherSuite, setSSLFipsRequired, setSSLPeerName, setSSLResetCount, setSSLSocketFactory, setStatusRefreshInterval, setSubscriptionStore, setSyncpointAllGets, setTargetClientMatching, setTemporaryModel, setTempQPrefix, setTransportType, setUseConnectionPooling
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cleanup

public Cleanup()
Default constructor.


Cleanup

public Cleanup(MQConnectionFactory mqcf)
        throws javax.jms.JMSException
Constructor that imports property values.

Parameters:
mqcf - the topic connection factory that provides the values.
Method Detail

setCleanupInterval

public void setCleanupInterval(long interval)
                        throws javax.jms.JMSException
Sets the cleanup interval.

Overrides:
setCleanupInterval in class MQConnectionFactory
Parameters:
interval - the cleanup interval in milliseconds.
Throws:
javax.jms.JMSException - if interval is either null or invalid.

getCleanupInterval

public long getCleanupInterval()
Gets the cleanup interval.

Overrides:
getCleanupInterval in class MQConnectionFactory
Returns:
the cleanup interval.

setCleanupLevel

public void setCleanupLevel(int level)
                     throws javax.jms.JMSException
Sets the cleanup level.

Overrides:
setCleanupLevel in class MQConnectionFactory
Parameters:
level - the cleanup level. The following values are accepted:
Throws:
javax.jms.JMSException - if level is not supported or if an illegal state is encountered.

getCleanupLevel

public int getCleanupLevel()
Gets the cleanup level.

Overrides:
getCleanupLevel in class MQConnectionFactory
Returns:
the cleanup level.
See Also:
setCleanupLevel(int level)

setPassword

public void setPassword(java.lang.String newPassword)
Sets the durable connection password

Parameters:
newPassword - the new password.

setUserID

public void setUserID(java.lang.String newuserID)
Sets the durable connection user ID.

Parameters:
newuserID - the new user ID.

main

public static void main(java.lang.String[] args)
                 throws java.io.UnsupportedEncodingException
Invokes the utility directly from a command line. You can use this if you use the broker-based subscription store. Syntax for bindings attach:

Cleanup [-m ] [-r ] [SAFE | STRONG | FORCE | NONDUR] [-t] Syntax for client attach:

Cleanup -client [-m ] -host [-port ] [-channel ] [-r ] [SAFE | STRONG | FORCE | NONDUR] [-t]

qmgr
the name of the queue manager.
hostname
the name of the host which is running the queue manager.
port
the port on which the queue manager is listening.
channel
the name of the channel.
interval
the interval between executions of cleanup, in minutes. If not set, cleanup is performed once. This option is not valid with cleanup types of FORCE or NONDUR.
-t
enables tracing, to the mqjms.trc file.
SAFE | STRONG | FORCE | NONDUR
sets type of clean up. See setCleanupLevel.

java.io.UnsupportedEncodingException

run

public void run()
Runs Cleanup. It runs in the background at intervals, as determined by setCleanupLevel() and setCleanupInterval. If the field set by setCleanupInterval() is zero, Cleanup runs once and returns. Otherwise Cleanup runs regularly at the time in milliseconds set by setCleanupInterval(). CleanupInterval must be zero with JMSC.MQJMS_CLEANUP_FORCE or JMSC.MQJMS_CLEANUP_NONDUR set, and CleanupLevel cannot be MQJMS_CLEANUP_NONE. In these cases the method fails with an IllegalStateException. Any exceptions generated are routed to the ExceptionListener.

Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Stops any running cleanup thread. Returns when run() has finished. Does nothing if run() is not running.


setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener el)
Sets the ExceptionListener. If set, the ExceptionListener receives any exceptions caused while run() is running. Cleanup terminates shortly after issuing the exception to the ExceptionListener.

Parameters:
el - the exception listener.

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
Gets the ExceptionListener.

Returns:
the exception listener.

isRunning

public boolean isRunning()
Indicates whether run() is currently active.

Returns:
true if active; false otherwise.

cleanup

public void cleanup()
             throws javax.jms.JMSException
Runs Cleanup once.

Throws:
javax.jms.IllegalStateException - if CleanupLevel is JMSC.MQJMS_CLEANUP_NONE.
javax.jms.JMSException

(c) Copyright IBM Corp. 2005. All Rights Reserved.