org.exolab.jms.messagemgr
Class QueueDestinationCache

java.lang.Object
  |
  +--org.exolab.jms.messagemgr.DestinationCache
        |
        +--org.exolab.jms.messagemgr.QueueDestinationCache
All Implemented Interfaces:
GarbageCollectable, Identifiable, LeaseEventListenerIfc, MessageManagerEventListener, java.io.Serializable

public class QueueDestinationCache
extends DestinationCache

A DestinationCache for Queues

Version:
$Revision: 1.34.2.1 $ $Date: 2004/05/01 12:05:26 $
Author:
Jim Alateras
See Also:
Serialized Form

Field Summary
protected  java.util.List _queueListeners
          Maintains a list of queue listeners for this cache
 
Fields inherited from class org.exolab.jms.messagemgr.DestinationCache
_consumers, _leaseHelper
 
Method Summary
 void addQueueListener(QueueListener listener)
          A Queue can also hav a queue listener, which simply gets informed of all messages that arrive at this destination
 boolean canDestroy()
          Determines if this cache can be destroyed.
 JmsDestination getDestination()
          Return a reference to the underlying destination
 MessageHandle getMessage(QueueConsumerEndpoint endpoint)
          Return the first message of the queue or null if there are no messages in the cache
 int hashCode()
           
 boolean messageAdded(JmsDestination destination, MessageImpl message)
          This method is called when the MessageMgr adds a message for this destination to the cache
 void messageRemoved(JmsDestination destination, MessageImpl message)
          This method is called when the MessageMgr removes a message from the cache.
 boolean persistentMessageAdded(java.sql.Connection connection, JmsDestination destination, MessageImpl message)
          This event is called when the MessageMgr adds a persistent message to the cache.
 void persistentMessageRemoved(java.sql.Connection connection, JmsDestination destination, MessageImpl message)
          This event is called when the MessageMgr removes a persistent message from the cache.
 void playbackMessages(QueueListener listener)
          Playback all the messages in the cache to the specified QueueListener
 void removeQueueListener(QueueListener listener)
          Remove the queue listener associated with this cache
 void returnMessage(MessageHandle handle)
          Return the specified message to top of the queue.
 java.lang.String toString()
           
 
Methods inherited from class org.exolab.jms.messagemgr.DestinationCache
collectGarbage, getConsumers, getDestinationByName, getId, getMaximumSize, getMessageCount, onLeaseExpired, registerConsumer, resolveExpiredMessage, setCacheEvictionPolicy, setMaximumSize, shutdown, unregisterConsumer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_queueListeners

protected java.util.List _queueListeners
Maintains a list of queue listeners for this cache
Method Detail

getDestination

public JmsDestination getDestination()
Description copied from class: DestinationCache
Return a reference to the underlying destination
Overrides:
getDestination in class DestinationCache
Following copied from class: org.exolab.jms.messagemgr.DestinationCache
Returns:
JmsDestination

addQueueListener

public void addQueueListener(QueueListener listener)
A Queue can also hav a queue listener, which simply gets informed of all messages that arrive at this destination
Parameters:
listener - - queue listener

removeQueueListener

public void removeQueueListener(QueueListener listener)
Remove the queue listener associated with this cache
Parameters:
listener - - queue listener to remove

messageAdded

public boolean messageAdded(JmsDestination destination,
                            MessageImpl message)
Description copied from class: DestinationCache
This method is called when the MessageMgr adds a message for this destination to the cache
Overrides:
messageAdded in class DestinationCache
Following copied from class: org.exolab.jms.messagemgr.DestinationCache
Parameters:
message - - message added to cache

messageRemoved

public void messageRemoved(JmsDestination destination,
                           MessageImpl message)
This method is called when the MessageMgr removes a message from the cache.
Overrides:
messageRemoved in class DestinationCache
Parameters:
destination - the message destination
message - the message removed from cache

persistentMessageAdded

public boolean persistentMessageAdded(java.sql.Connection connection,
                                      JmsDestination destination,
                                      MessageImpl message)
                               throws PersistenceException
Description copied from interface: MessageManagerEventListener
This event is called when the MessageMgr adds a persistent message to the cache.
Following copied from interface: org.exolab.jms.messagemgr.MessageManagerEventListener
Parameters:
connection - the database connection
destination - the message's destination
message - message added to cache
Returns:
trueThrows:
PersistenceException - if there is a persistence related problem

persistentMessageRemoved

public void persistentMessageRemoved(java.sql.Connection connection,
                                     JmsDestination destination,
                                     MessageImpl message)
                              throws PersistenceException
Description copied from interface: MessageManagerEventListener
This event is called when the MessageMgr removes a persistent message from the cache.
Following copied from interface: org.exolab.jms.messagemgr.MessageManagerEventListener
Parameters:
connection - the database connection
message - message to remove from cache
destination - the message's destination
Throws:
PersistenceException - - if there is a persistence related problem

getMessage

public MessageHandle getMessage(QueueConsumerEndpoint endpoint)
Return the first message of the queue or null if there are no messages in the cache
Parameters:
QueueConsumerEndpoint - - the consumer who will receive the message
Returns:
MessageHandle - handle to the first message

playbackMessages

public void playbackMessages(QueueListener listener)
Playback all the messages in the cache to the specified QueueListener
Parameters:
listener - - the queue listener

returnMessage

public void returnMessage(MessageHandle handle)
Return the specified message to top of the queue. This is called to recover unsent or unacked messages
Parameters:
message - - message to return

canDestroy

public boolean canDestroy()
Determines if this cache can be destroyed. A QueueDestinationCache can be destroyed if there are no active consumers and:
  • the queue is persistent and there are no messages
  • the queue is temporary and the corresponding connection is closed
Overrides:
canDestroy in class DestinationCache
Returns:
true if the cache can be destroyed, otherwise false

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 1999-2004 The OpenJMS Group. All Rights Reserved.