org.exolab.jms.messagemgr
Class QueueBrowserEndpoint

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

public class QueueBrowserEndpoint
extends AbstractConsumerEndpoint

A QueueBrowserEndpoint is a QueueListener to a QueueDestinationCache. This enables it to receive all the messages, which it then feeds down to the client side.

Version:
$Revision: 1.3 $ $Date: 2005/08/30 07:26:49 $
Author:
Jim Alateras, Tim Anderson

Constructor Summary
QueueBrowserEndpoint(long consumerId, QueueDestinationCache cache, java.lang.String selector)
          Create a new QueueBrowserEndpoint.
 
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 in the cache for this consumer.
 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

QueueBrowserEndpoint

public QueueBrowserEndpoint(long consumerId,
                            QueueDestinationCache cache,
                            java.lang.String selector)
                     throws javax.jms.InvalidSelectorException,
                            javax.jms.JMSException
Create a new QueueBrowserEndpoint.
Parameters:
consumerId - the identity of this consumer
cache - the destination cache
selector - the message selector. May be null
Throws:
javax.jms.InvalidSelectorException - if selector is invalid
javax.jms.JMSException - if the destination cache can't be created
Method Detail

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

getMessageCount

public int getMessageCount()
Return the number of unsent messages in the cache for this consumer.
Returns:
the number of unsent messages

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.