|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.jms.messagemgr.AbstractConsumerEndpoint
org.exolab.jms.messagemgr.DurableConsumerEndpoint
public class DurableConsumerEndpoint
A ConsumerEndpoint
for durable topic consumers. The state of durable
topic consumers is maintained across server invocations by the persistent
layer.
Field Summary | |
---|---|
protected java.util.Map |
_caches
Maintains a map of TopicDestinationCache that this endpoint subscribes to, keyed on JmsTopic. |
Constructor Summary | |
---|---|
DurableConsumerEndpoint(long consumerId,
JmsTopic topic,
java.lang.String name,
DestinationManager destinations)
Construct a new DurableConsumerEndpoint . |
Method Summary | |
---|---|
void |
activate(long connectionId,
java.lang.String selector,
boolean noLocal)
Activate this durable consumer. |
protected void |
addMessage(MessageHandle handle)
Add the handle to the cache. |
void |
cacheAdded(JmsDestination destination,
DestinationCache cache)
Invoked when a message cache is created. |
void |
cacheRemoved(JmsDestination destination,
DestinationCache cache)
Invoked when a message cache is removed. |
boolean |
canConsume(JmsDestination destination)
Determines if this consumer can consume messages from the specified destination. |
void |
deactivate()
Deactivate this durable consumer. |
void |
destinationAdded(JmsDestination destination)
Invoked when a destination is created. |
void |
destinationRemoved(JmsDestination destination)
Invoked when a destination is removed. |
protected void |
doClose()
Closes this endpoint. |
protected MessageHandle |
doReceive(Condition cancel)
Return the next available message to the client. |
long |
getConnectionId()
Returns the identity of the connection that owns this consumer. |
protected DestinationCache[] |
getDestinationCaches()
Returns the destination caches. |
protected DestinationManager |
getDestinationManager()
Returns the destination manager. |
int |
getMessageCount()
Return the number of unsent messages in the cache for this consumer. |
java.lang.String |
getPersistentId()
Returns the persistent identifier for this consumer. |
protected void |
init()
Registers this with the associated DestinationCache s. |
boolean |
isActive()
Determines if the endpoint is active. |
boolean |
isPersistent()
Determines if this is a persistent or non-persistent consumer. |
boolean |
messageAdded(MessageHandle handle,
MessageImpl message)
This event is called when a non-persistent message is added to the DestinationCache . |
void |
messageRemoved(java.lang.String messageId)
This event is called when a message is removed from the DestinationCache . |
boolean |
persistentMessageAdded(MessageHandle handle,
MessageImpl message)
This event is called when a persistent message is added to the DestinationCache . |
void |
persistentMessageRemoved(java.lang.String messageId)
This event is called when a message is removed from the DestinationCache . |
void |
returnMessage(MessageHandle handle)
Return a delivered, but unacknowledged message to the cache. |
protected void |
setConnectionId(long connectionId)
Set the connection identifier. |
Methods inherited from class org.exolab.jms.messagemgr.AbstractConsumerEndpoint |
---|
close, getDestination, getId, getNoLocal, getSelector, isAsynchronous, isClosed, isWaitingForMessage, notifyMessageAvailable, receive, selects, setAsynchronous, setListener, setNoLocal, setSelector, setWaitingForMessage, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Map _caches
Constructor Detail |
---|
public DurableConsumerEndpoint(long consumerId, JmsTopic topic, java.lang.String name, DestinationManager destinations) throws javax.jms.InvalidSelectorException, javax.jms.JMSException, PersistenceException
DurableConsumerEndpoint
.
The consumer is inactive until made active via activate(long, java.lang.String, boolean)
.
consumerId
- the identity of this consumertopic
- the topic to accessdestinations
- the destination managername
- the well known name of the durable subscriber
javax.jms.InvalidSelectorException
- if the selector is invalid
javax.jms.JMSException
- if the destination caches can't be
constructed
PersistenceException
- for any persistence errorMethod Detail |
---|
public boolean isPersistent()
getPersistentId()
returns a non-null value
isPersistent
in interface ConsumerEndpoint
isPersistent
in class AbstractConsumerEndpoint
true
public java.lang.String getPersistentId()
getPersistentId
in interface ConsumerEndpoint
getPersistentId
in class AbstractConsumerEndpoint
public void activate(long connectionId, java.lang.String selector, boolean noLocal) throws javax.jms.JMSException
connectionId
- the identity of the connection that owns this
consumerselector
- the message selector. May be null
noLocal
- if true, inhibits the delivery of messages published
by its own connection.
javax.jms.JMSException
- if the consumer can't be activated
javax.jms.InvalidSelectorException
- if the selector is invalidpublic void deactivate() throws javax.jms.JMSException
javax.jms.JMSException
- if the consumer can't be deactivatedpublic boolean isActive()
true
if the endpoint is active, false
if it is inactivepublic long getConnectionId()
-1
if this is not
currently associated with a connection.ServerConnection.getConnectionId()
public boolean canConsume(JmsDestination destination)
canConsume
in interface ConsumerEndpoint
canConsume
in class AbstractConsumerEndpoint
destination
- the destination
true
if the consumer can consume messages from
destination
; otherwise false
public void returnMessage(MessageHandle handle)
handle
- the handle of the message to returnpublic int getMessageCount()
getMessageCount
in interface ConsumerEndpoint
public boolean messageAdded(MessageHandle handle, MessageImpl message) throws javax.jms.JMSException
DestinationCache
.
handle
- a handle to the messagemessage
- the added message
true
if the listener accepted the message; otherwise
false
- Throws:
javax.jms.JMSException
- if the listener fails to handle the message
public void messageRemoved(java.lang.String messageId) throws javax.jms.JMSException
DestinationCache
.
messageId
- the identifier of the removed message
javax.jms.JMSException
- if the listener fails to handle the messagepublic boolean persistentMessageAdded(MessageHandle handle, MessageImpl message) throws javax.jms.JMSException, PersistenceException
DestinationCache
.
handle
- a handle to the added messagemessage
- the added message
true
if the listener accepted the message;
javax.jms.JMSException
- if the listener fails to handle the message
PersistenceException
- if there is a persistence related problempublic void persistentMessageRemoved(java.lang.String messageId) throws javax.jms.JMSException, PersistenceException
DestinationCache
.
messageId
- the identifier of the removed message
javax.jms.JMSException
- if the listener fails to handle the message
PersistenceException
- if there is a persistence related problempublic void destinationAdded(JmsDestination destination)
destinationAdded
in interface DestinationEventListener
destination
- the destination that was addedpublic void destinationRemoved(JmsDestination destination)
destinationRemoved
in interface DestinationEventListener
destination
- the destination that was removedpublic void cacheAdded(JmsDestination destination, DestinationCache cache)
cacheAdded
in interface DestinationEventListener
destination
- the destination that messages are being cached forcache
- the corresponding cachepublic void cacheRemoved(JmsDestination destination, DestinationCache cache)
cacheRemoved
in interface DestinationEventListener
destination
- the destination that messages are no longer being
cached forcache
- the corresponding cacheprotected void init() throws javax.jms.JMSException
DestinationCache
s. The
consumer may receive messages immediately.
javax.jms.JMSException
- for any JMS errorprotected void setConnectionId(long connectionId)
connectionId
- the identity of the connection that owns this
consumergetConnectionId()
protected void addMessage(MessageHandle handle)
handle
- the message handle to addprotected MessageHandle doReceive(Condition cancel) throws javax.jms.JMSException
doReceive
in class AbstractConsumerEndpoint
cancel
-
null
if none is available
javax.jms.JMSException
- for any errorprotected void doClose()
doClose
in class AbstractConsumerEndpoint
protected DestinationManager getDestinationManager()
protected DestinationCache[] getDestinationCaches()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |