|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.exolab.jms.messagemgr.DestinationCache
A DestinationCache is used to cache messages for a particular destination.
It implements MessageManagerEventListener
in order to be notified
of messages being added to and removed from
MessageMgr
A ConsumerEndpoint
registers with a DestinationCache
to
receive messages for a particular destination.
In all instances this class doesn't deal with Message
objects
directly, but instead uses their corresponding MessageHandle
,
which is far more lightweight.
A two level cache is used to facilitate quick seeding of registered
consumers and quick per-consumer-acknowledgment strategy. The two level
cache includes this, the DestinationCache, at the highest level and then
ConsumerManager
at the lowest level.
In addition to registering ConsumerEndpoint
objects the cache also
supports DestinationCacheEventListener
s. A listener will be
notified when messages are added to the cache but do not actually consume
messages. A cache can have one or more registered listeners. This feature is
predominately used by browsers or iterators of destinations.
Clients can also become lifecycle listeners for this object to get notified during initialization and shutdwon.
This cache is ordered on priority.
Field Summary | |
protected java.util.List |
_consumers
This is the list of consumers that have subscribed to this cache. |
protected MessageLeaseHelper |
_leaseHelper
The message lease helper is used to manage leases for messages cached by the destination |
Method Summary | |
abstract boolean |
canDestroy()
Determines if this cache can be destroyed |
void |
collectGarbage(boolean aggressive)
Perform any garbage collection on this resource. |
java.util.Iterator |
getConsumers()
Return an enmeration of all consumers attached to this cache. |
abstract JmsDestination |
getDestination()
Return a reference to the underlying destination |
java.lang.String |
getDestinationByName()
Return the string form of the destination |
java.lang.String |
getId()
Return the identity of the object |
int |
getMaximumSize()
Return the cache's maximum size |
int |
getMessageCount()
Return the number of messages currently active for this destination |
abstract boolean |
messageAdded(JmsDestination destination,
MessageImpl message)
This method is called when the MessageMgr adds a message
for this destination to the cache |
abstract void |
messageRemoved(JmsDestination destination,
MessageImpl message)
This method is called when the MessageMgr removes a
message from the cache. |
void |
onLeaseExpired(java.lang.Object leasedObject)
This method is called whenever a lease expires. |
boolean |
registerConsumer(ConsumerEndpoint consumer)
Register a consumer with this cache. |
protected MessageImpl |
resolveExpiredMessage(MessageHandle handle)
Resolve an expired message through its handle |
void |
setCacheEvictionPolicy(CacheEvictionPolicy policy)
Set the CacheEvictionPolicy for this object. |
void |
setMaximumSize(int size)
Set the maximum size of the cache. |
void |
shutdown()
Close the cache and unregister all the consumers. |
void |
unregisterConsumer(ConsumerEndpoint consumer)
Remove the consumer for the list of registered consumers. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.exolab.jms.messagemgr.MessageManagerEventListener |
persistentMessageAdded, persistentMessageRemoved |
Field Detail |
protected java.util.List _consumers
protected MessageLeaseHelper _leaseHelper
Method Detail |
public void setMaximumSize(int size)
CacheEvictionPolicy
is enforced
to remove messages.size
- - maximum number of messages a destination can holdpublic int getMaximumSize()
public abstract JmsDestination getDestination()
public java.lang.String getDestinationByName()
public void setCacheEvictionPolicy(CacheEvictionPolicy policy)
CacheEvictionPolicy
for this object. This determines
how messages are removed when the cache's upper limit is reached.policy
- the eviction policypublic boolean registerConsumer(ConsumerEndpoint consumer)
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.
consumer
- - message consumer for this destinationpublic void unregisterConsumer(ConsumerEndpoint consumer)
consumer
- - consumer to remove.public java.util.Iterator getConsumers()
public abstract boolean messageAdded(JmsDestination destination, MessageImpl message)
MessageMgr
adds a message
for this destination to the cachemessageAdded
in interface MessageManagerEventListener
message
- - message added to cachepublic abstract void messageRemoved(JmsDestination destination, MessageImpl message)
MessageMgr
removes a
message from the cache.messageRemoved
in interface MessageManagerEventListener
message
- - message removed from cachepublic int getMessageCount()
public void onLeaseExpired(java.lang.Object leasedObject)
onLeaseExpired
in interface LeaseEventListenerIfc
leasedObject
- reference to the leased objectpublic abstract boolean canDestroy()
true
if the cache can be destroyed, otherwise
false
public void shutdown()
Once the cache is closed it will no longger receive messages for this destination.
public java.lang.String getId()
Identifiable
getId
in interface Identifiable
org.exolab.jms.Identifiable
public void collectGarbage(boolean aggressive)
GarbageCollectable
collectGarbage
in interface GarbageCollectable
org.exolab.jms.gc.GarbageCollectable
aggressive
- - true for aggressive garbage collectionprotected MessageImpl resolveExpiredMessage(MessageHandle handle)
handle
- the expired message's handle
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |