|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.exolab.jms.messagemgr.ConsumerEndpoint
A Consumer is a message subscriber with a unique identity
Field Summary | |
protected int |
_ackMode
The acknowledgement mode for this endpoint. |
protected int |
_connectionId
Holds the connection id of the connection that the endpoint belongs too |
protected InternalMessageListener |
_listener
Holds the consumer's message listener. |
protected boolean |
_nolocal
The nolocal indicator, if set, inhibits consuming messages that have been published on the same connection |
protected Scheduler |
_scheduler
This is the scheduler that is used to deliver messages if a consumer has a registered listener |
protected Selector |
_selector
The selector assoicated with this consumer. |
protected JmsServerSession |
_session
caches the session that created this endpoint |
protected int |
_size
Maintains the maximum size of this cache |
protected boolean |
_transacted
Indicates whether this endpoint belongs to a transacted session |
protected boolean |
_waitingForMessage
Used to block consumer until there is a message available |
protected java.lang.Object |
_waitingForMessageMonitor
Serializes access to the _waitingForMessage flag. |
Method Summary | |
protected void |
addMessage(MessageHandle handle)
Add the handle to the cache |
protected void |
addMessage(MessageHandle handle,
MessageImpl message)
Cache a handle and its corresponding message |
protected void |
clearMessages()
Clear all messages in the cache, regardless of whether they are persistent or non-persistent |
protected void |
clearWaitingForMessage()
Clear the waiting for message flag |
void |
close()
Close this endpoint. |
void |
collectGarbage(boolean aggressive)
|
protected boolean |
collectionHasPersistentHandles(java.util.Vector collection)
Check whether the vector of handles contains one or more persistent handles |
protected boolean |
containsMessage(MessageHandle handle)
Determines if a message handle is already cached |
protected void |
deleteMessage(MessageHandle handle)
Delete the message with the specified handle from the cache |
abstract boolean |
deliverMessages()
Deliver messages in the cache to the consumer |
protected abstract void |
doClose()
Closes the endpoint |
int |
getAckMode()
Return the ackmode for this endpoint |
long |
getClientId()
Return a reference to the client identity. |
int |
getConnectionId()
Return the connection id that this endpoint belongs to |
abstract JmsDestination |
getDestination()
Return the destination that this consumer is subscribed to |
java.lang.String |
getId()
Return the identity of the object |
int |
getMaximumSize()
Return the cache's maximum size |
protected MessageImpl |
getMessage(MessageHandle handle)
Return the message for the specified handle |
int |
getMessageCount()
Return the number of unsent messages in the cache for this consumer |
boolean |
getNoLocal()
Return the value of the nolocal indicator |
java.lang.String |
getPersistentId()
Returns the persistent identifier for this consumer. This is the identity of the consumer which is persistent across subscriptions and server restarts. |
Selector |
getSelector()
Return the selector for this endpoint or null if one is not specified |
JmsServerSession |
getSession()
Return a reference to the session owning this endpoint |
boolean |
getTransacted()
Check whether this endpoint belongs to a transacted session |
int |
hashCode()
|
protected boolean |
isStopped()
Determines if this endpoint has been stopped |
protected boolean |
isWaitingForMessage()
Check whether the endpoint is waiting for a message |
boolean |
messageAdded(MessageImpl message)
This event is called when a non-persistent message is added to the DestinationCache. |
boolean |
messageRemoved(MessageImpl message)
This event is called when a message is removed from the DestinationCache. |
protected void |
notifyMessageAvailable()
Check if the consumer is waiting for a message. |
boolean |
persistentMessageAdded(java.sql.Connection connection,
MessageImpl message)
This event is called when a persistent message is added to the DestinationCache. |
boolean |
persistentMessageRemoved(java.sql.Connection connection,
MessageImpl message)
This event is called when a message is removed from the DestinationCache. |
abstract MessageHandle |
receiveMessage(long wait)
Return the next message to the client. |
void |
recover()
This message will return all unacked messages to the queue and allow them to be resent to the consumer with the redelivery flag on. |
protected MessageHandle |
removeFirstMessage()
Return the first message handle in the cache |
protected boolean |
removeMessage(MessageHandle handle)
Remove the handle from the cache |
void |
returnMessage(MessageHandle handle)
Return the specified message to the cache. |
void |
run()
The run method is used to asynchronously deliver the messages in the cache to the consumer, by invoking deliverMessages() . |
protected void |
schedule()
Schedule asynchronouse message delivery |
void |
setAckMode(int ackmode)
Set the ackMode for this endpoint |
void |
setCacheEvictionPolicy(CacheEvictionPolicy policy)
Set the CacheEvictionPolicy for this object. |
void |
setConnectionId(int id)
Set the connection that this endpooint belongs too |
void |
setMaximumSize(int size)
Set the maximum size of the cache. |
void |
setMessageListener(InternalMessageListener listener)
Set the message listener for this consmer. |
void |
setNoLocal(boolean nolocal)
Set the no local indicator for this endpoint |
void |
setSelector(java.lang.String selector)
Set the selector for this endpoint |
void |
setStopped(boolean stop)
Stop/start message delivery |
void |
setTransacted(boolean transacted)
Set the state if the transacted flag for this endpoint |
protected void |
setWaitingForMessage()
Set the waiting for message flag |
protected boolean |
stopDelivery()
Helper for deliverMessages() implementations, to determines if
asynchronous message delivery should be stopped |
java.lang.String |
toString()
Return a stringified version of the consumer |
abstract void |
unregister()
Unregister this consumer for the specified destination cache, so that it will stop receiving messages from it. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Selector _selector
protected final java.lang.Object _waitingForMessageMonitor
_waitingForMessage
flag. This is
only required when it is changedprotected boolean _waitingForMessage
protected InternalMessageListener _listener
protected int _size
protected transient Scheduler _scheduler
protected transient int _ackMode
protected transient boolean _nolocal
protected transient boolean _transacted
protected transient int _connectionId
protected JmsServerSession _session
Method Detail |
public abstract JmsDestination getDestination()
public java.lang.String getId()
Identifiable
getId
in interface Identifiable
org.exolab.jms.Identifiable
public java.lang.String getPersistentId()
getId()
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public abstract void unregister()
public long getClientId()
public Selector getSelector()
public void setSelector(java.lang.String selector) throws javax.jms.InvalidSelectorException
selector
- - message selector as a stringjavax.jms.InvalidSelectorException
- - raised when selector is not
well-formedpublic int getAckMode()
public void setAckMode(int ackmode)
ackmode
- - the new ack mode for the endpointpublic int getConnectionId()
public void setConnectionId(int id)
id
- - connection identitypublic boolean getNoLocal()
public void setNoLocal(boolean nolocal)
nolocal
- - true to inhibit messages published on this connectionpublic boolean getTransacted()
public void setTransacted(boolean transacted)
transacted
- - true if it is transactedpublic void setMaximumSize(int size)
CacheEvictionPolicy
is enforced
to remove messages.size
- - maximum number of messages a destination can holdpublic int getMaximumSize()
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 int getMessageCount()
public JmsServerSession getSession()
public abstract boolean deliverMessages()
true
if the endpoint should be rescheduledpublic void run()
deliverMessages()
.
It is scheduled by the Scheduler
.
run
in interface java.lang.Runnable
public boolean messageAdded(MessageImpl message)
DestinationCacheEventListener
messageAdded
in interface DestinationCacheEventListener
org.exolab.jms.messagemgr.DestinationCacheEventListener
message
- - message added to cachepublic boolean messageRemoved(MessageImpl message)
DestinationCacheEventListener
messageRemoved
in interface DestinationCacheEventListener
org.exolab.jms.messagemgr.DestinationCacheEventListener
message
- - message removed from cachepublic boolean persistentMessageAdded(java.sql.Connection connection, MessageImpl message) throws PersistenceException
DestinationCacheEventListener
persistentMessageAdded
in interface DestinationCacheEventListener
org.exolab.jms.messagemgr.DestinationCacheEventListener
connection
- - the database connectionmessage
- - message added to cachePersistenceException
- - if there is a persistence related problempublic boolean persistentMessageRemoved(java.sql.Connection connection, MessageImpl message) throws PersistenceException
DestinationCacheEventListener
persistentMessageRemoved
in interface DestinationCacheEventListener
org.exolab.jms.messagemgr.DestinationCacheEventListener
connection
- - the database connectionmessage
- - message to remove from cachePersistenceException
- - if there is a persistence related problempublic void setStopped(boolean stop)
stop
- if true
to stop message delivery, otherwise
start itpublic void recover()
public final void close()
This synchronizes with deliverMessages()
before invoking
public void setMessageListener(InternalMessageListener listener)
Each consumer cache can only have a single message listener. To remove the message listener call this method with null argument
listener
- - the message listener to add.public void returnMessage(MessageHandle handle)
handle
- - handle to returnpublic abstract MessageHandle receiveMessage(long wait)
wait
- - the number of milliseconds to waitpublic void collectGarbage(boolean aggressive)
protected abstract void doClose()
protected void schedule()
protected void clearMessages()
protected boolean collectionHasPersistentHandles(java.util.Vector collection)
handles
- - collection of MessageHandle
objectsprotected void addMessage(MessageHandle handle)
handle
- - the message handle to addprotected void addMessage(MessageHandle handle, MessageImpl message)
handle
- the handle to cachemessage
- the corresponding message to cacheprotected MessageImpl getMessage(MessageHandle handle)
handle
- - the handleprotected boolean removeMessage(MessageHandle handle)
handle
- the handle to removetrue
if the message was removedprotected boolean containsMessage(MessageHandle handle)
true
if it is cachedprotected MessageHandle removeFirstMessage()
protected void deleteMessage(MessageHandle handle)
handle
- the handleprotected final boolean isStopped()
true
if this endpoint has been stoppedprotected void notifyMessageAvailable()
protected final boolean isWaitingForMessage()
protected final void setWaitingForMessage()
protected final void clearWaitingForMessage()
protected boolean stopDelivery()
deliverMessages()
implementations, to determines if
asynchronous message delivery should be stoppedtrue
if asynchronous message delivery should be
stopped
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |