org.exolab.jms.messagemgr
Class TopicDestinationCache

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

public class TopicDestinationCache
extends DestinationCache

A DestinationCache for Topics. This cache extends DestinationCache but does not actually hold a reference to the messages. Instead it forwards them on to registered consumers.

We may need to build the cache for clients that fail over to the new server so we should maintain a cache of at least persistent messages handles. This is something that needs to be considered. As for non-persistent messages well that is the penalty for using them. If you want to ensure that you get every message, even during failover then you best publsih them using persistent delivery mode.

Version:
$Revision: 1.22 $ $Date: 2003/10/21 14:41:24 $
Author:
Jim Alateras
See Also:
Serialized Form

Fields inherited from class org.exolab.jms.messagemgr.DestinationCache
_consumers, _leaseHelper
 
Method Summary
 boolean canDestroy()
          Determines if this cache can be destroyed.
 JmsDestination getDestination()
          Return a reference to the underlying destination
 int getMessageCount()
          Return the number of messages currently active for this destination
 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.
 boolean registerConsumer(ConsumerEndpoint consumer)
          Register a consumer with this cache.
protected  MessageImpl resolveExpiredMessage(MessageHandle handle)
          Resolve an expired message through its handle
 java.lang.String toString()
           
 
Methods inherited from class org.exolab.jms.messagemgr.DestinationCache
collectGarbage, getConsumers, getDestinationByName, getId, getMaximumSize, onLeaseExpired, setCacheEvictionPolicy, setMaximumSize, shutdown, unregisterConsumer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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

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)
Description copied from class: DestinationCache
This method is called when the MessageMgr removes a message from the cache.
Overrides:
messageRemoved in class DestinationCache
Following copied from class: org.exolab.jms.messagemgr.DestinationCache
Parameters:
message - - 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

registerConsumer

public boolean registerConsumer(ConsumerEndpoint consumer)
Description copied from class: DestinationCache
Register a consumer with this cache. Part of the registration process will be to seed the ConsumerEndpoint with an initial list of messages that it needs to consume and then feed messages to it through the specified listener object.

Messages are subsequently passed down to the consumer's through the listener, as they enter the DestinationCache.

Overrides:
registerConsumer in class DestinationCache
Following copied from class: org.exolab.jms.messagemgr.DestinationCache
Parameters:
consumer - - message consumer for this destination
Returns:
boolean - true if registered and false otherwise

getMessageCount

public int getMessageCount()
Description copied from class: DestinationCache
Return the number of messages currently active for this destination
Overrides:
getMessageCount in class DestinationCache
Following copied from class: org.exolab.jms.messagemgr.DestinationCache
Returns:
int - number of active messages

canDestroy

public boolean canDestroy()
Determines if this cache can be destroyed. A TopicDestinationCache can be destroyed if there are no active consumers.
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

resolveExpiredMessage

protected MessageImpl resolveExpiredMessage(MessageHandle handle)
Resolve an expired message through its handle
Overrides:
resolveExpiredMessage in class DestinationCache
Parameters:
handle - the expired message's handle
Returns:
the expired message. May be null.


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