|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--jrun.jms.core.messagemgr.DestinationCache
A DestinationCache, as the name implies, is used to cache messages
for a particular #Destination object. It is also a
#MessageHandleListener that subscribes to the registers with a #DestinationCache to receive
messages for a particular {@Destination}.
In all instances this class doesn't deal with {@link #Message} objects directly, but instead uses their corresponding {@link #MessageHandle}, which is far more lightwieght.
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 {@link #ConsumerCache} at the lowest level.
In addition to registering {@link ConsumerEndpoint} objects the cache also supports {@link MessageHandleListener}s. A listener will be notified when messages are added to the cache but do not actually consume messages. A cache canb 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 |
protected MessageQueue |
_messages
Transient cache of all messages sent to this destination |
protected static PersistentAdapter |
m_persistentAdapter
|
| Method Summary | |
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 |
long |
getId()
Return the identity of the object as a long |
java.lang.String |
getIdAsString()
Return the identity of the object as a string |
protected Logger |
getLogger()
Return a reference to the logger |
int |
getMaximumSize()
Return the cache's maximum size |
abstract 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 #MessageManager adds a message
for this destination to the cache |
abstract void |
messageRemoved(JmsDestination destination,
MessageImpl message)
This method is called when the {@l;ink #MessageManager} removes a message from the cache. |
void |
onLeaseExpired(java.lang.Object leasedObject)
This method is called whenever a lease expires. |
void |
onSchedulableEvent(java.lang.Object context,
int type)
This method is called whenever a schedulableEvent gets fired. |
abstract void |
persistentMessageRemoved(JmsDestination destination,
MessageImpl message)
This method is called when the {@l;ink #MessageManager} removes a persistent message from the cache. |
boolean |
registerConsumer(ConsumerEndpoint consumer)
Register a consumer with this cache. |
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 jrun.jms.core.messagemgr.MessageManagerEventListener |
persistentMessageAdded |
| Field Detail |
protected static PersistentAdapter m_persistentAdapter
protected MessageQueue _messages
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. If no
policy is specified then the default #LifoEvictionPolicy is
applied.policy - - cache's 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)
#MessageManager adds a message
for this destination to the cachemessageAdded in interface MessageManagerEventListenermessage - - message added to cache
public abstract void messageRemoved(JmsDestination destination,
MessageImpl message)
messageRemoved in interface MessageManagerEventListenermessage - - message removed from cache
public abstract void persistentMessageRemoved(JmsDestination destination,
MessageImpl message)
throws PersistenceException
persistentMessageRemoved in interface MessageManagerEventListenermessage - - message removed from cachepublic abstract int getMessageCount()
public void onSchedulableEvent(java.lang.Object context,
int type)
SchedulableEventListeneronSchedulableEvent in interface SchedulableEventListenerpublic void onLeaseExpired(java.lang.Object leasedObject)
leasedObject - reference to the leased objectpublic void shutdown()
Once the cache is closed it will no longger receive messages for this destination.
protected Logger getLogger()
public long getId()
IdentifiablegetId in interface Identifiablejrun.jms.core.Identifiablepublic java.lang.String getIdAsString()
IdentifiablegetIdAsString in interface Identifiablejrun.jms.core.Identifiable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||