org.exolab.jms.messagemgr
Class QueueConsumerEndpoint

java.lang.Object
  |
  +--org.exolab.jms.messagemgr.AbstractConsumerEndpoint
        |
        +--org.exolab.jms.messagemgr.QueueConsumerEndpoint
All Implemented Interfaces:
ConsumerEndpoint, org.exolab.jms.messagemgr.DestinationCacheEventListener

public class QueueConsumerEndpoint
extends AbstractConsumerEndpoint

A ConsumerEndpoint for queues. This object shares access to a particular queue with other QueueConsumerEndpoint instances.

Version:
$Revision: 1.3 $ $Date: 2005/08/30 05:30:52 $
Author:
Jim Alateras, Tim Anderson

Constructor Summary
QueueConsumerEndpoint(long consumerId, QueueDestinationCache cache, java.lang.String selector)
          Construct a new QueueConsumerEndpoint.
 
Method Summary
protected  void doClose()
          Closes this endpoint.
protected  MessageHandle doReceive(Condition cancel)
          Return the next available message to the client.
 int getMessageCount()
          Return the number of unsent messages.
 boolean messageAdded(MessageHandle handle, MessageImpl message)
          This event is called when a non-persistent message is added to a 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
 
Methods inherited from class org.exolab.jms.messagemgr.AbstractConsumerEndpoint
canConsume, close, getDestination, getId, getNoLocal, getPersistentId, getSelector, isAsynchronous, isClosed, isPersistent, 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
 

Constructor Detail

QueueConsumerEndpoint

public QueueConsumerEndpoint(long consumerId,
                             QueueDestinationCache cache,
                             java.lang.String selector)
                      throws javax.jms.InvalidSelectorException,
                             javax.jms.JMSException
Construct a new QueueConsumerEndpoint.
Parameters:
consumerId - the identity of this consumer
cache - the cache to register with
Throws:
javax.jms.InvalidSelectorException - if the selector is not well formed
javax.jms.JMSException - if the destination cache can't be created
Method Detail

getMessageCount

public int getMessageCount()
Return the number of unsent messages.
Returns:
the number of unsent messages

messageAdded

public boolean messageAdded(MessageHandle handle,
                            MessageImpl message)
This event is called when a non-persistent message is added to a DestinationCache.
Parameters:
handle - a handle to the added message
message - the added message
Returns:
true if the listener accepted the message; otherwise false

persistentMessageAdded

public boolean persistentMessageAdded(MessageHandle handle,
                                      MessageImpl message)
This event is called when a persistent message is added to the DestinationCache.
Parameters:
handle - a handle to the added message
message - the added message
Returns:
true

messageRemoved

public void messageRemoved(java.lang.String messageId)
This event is called when a message is removed from the DestinationCache.
Parameters:
messageId - the identifier of the removed message

persistentMessageRemoved

public void persistentMessageRemoved(java.lang.String messageId)
This event is called when a message is removed from the DestinationCache
Parameters:
messageId - a handle to the removed message

doReceive

protected MessageHandle doReceive(Condition cancel)
                           throws javax.jms.JMSException
Return the next available message to the client.
Overrides:
doReceive in class AbstractConsumerEndpoint
Parameters:
cancel -  
Returns:
the next message, or null if none is available
Throws:
javax.jms.JMSException - for any error

doClose

protected void doClose()
Closes this endpoint.
Overrides:
doClose in class AbstractConsumerEndpoint


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