org.exolab.jms.messagemgr
Interface ConsumerEndpoint

All Superinterfaces:
org.exolab.jms.messagemgr.DestinationCacheEventListener
All Known Implementing Classes:
AbstractConsumerEndpoint

public interface ConsumerEndpoint
extends org.exolab.jms.messagemgr.DestinationCacheEventListener

ConsumerEndpoint represents the server-side view of of the MessageConsumer and QueueBrowser interfaces

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

Method Summary
 boolean canConsume(JmsDestination destination)
          Determines if this consumer can consume messages from the specified destination.
 void close()
          Close and release any resource allocated to this endpoint.
 JmsDestination getDestination()
          Return the destination that this consumer is accessing.
 long getId()
          Returns the identity of this consumer.
 int getMessageCount()
          Returns the number of unsent messages in the cache.
 boolean getNoLocal()
          Returns if locally produced messages are being inhibited.
 java.lang.String getPersistentId()
          Returns the persistent identifier for this consumer.
 Selector getSelector()
          Returns the message selector.
 boolean isAsynchronous()
          Determines if this is an asynchronous consumer.
 boolean isClosed()
          Determines if this consumer is closed, or in the process of being closed.
 boolean isPersistent()
          Determines if this is a persistent or non-persistent consumer.
 boolean isWaitingForMessage()
          Determines if the client is currently waiting for a message.
 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.
 MessageHandle receive(Condition cancel)
          Return the next available message to the client.
 boolean selects(MessageImpl message)
          Determines if a message is selected by the consumer.
 void setAsynchronous(boolean asynchronous)
          Indicates if this is an asynchronous consumer.
 void setListener(ConsumerEndpointListener listener)
          Set the listener for this consumer.
 void setWaitingForMessage(Condition condition)
          Indicates that the client is currently waiting for a message.
 

Method Detail

getId

public long getId()
Returns the identity of this consumer.
Returns:
the identity of this consumer

isPersistent

public boolean isPersistent()
Determines if this is a persistent or non-persistent consumer.

If persistent, then the consumer is persistent accross subscriptions and server restarts, and getPersistentId() returns a non-null value

Returns:
true if this is a persistent consumer; otherwise false

getPersistentId

public 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.
Returns:
the persistent identifier for this consumer, or null if this is a transient consumer

getDestination

public JmsDestination getDestination()
Return the destination that this consumer is accessing.
Returns:
the destination that this consumer is accessing

canConsume

public boolean canConsume(JmsDestination destination)
Determines if this consumer can consume messages from the specified destination.
Parameters:
destination - the destination
Returns:
true if the consumer can consume messages from destination; otherwise false

getSelector

public Selector getSelector()
Returns the message selector.
Returns:
the message selector, or null if none was specified by the client

selects

public boolean selects(MessageImpl message)
Determines if a message is selected by the consumer.
Parameters:
message - the message to check
Returns:
true if the message is selected; otherwise false

getNoLocal

public boolean getNoLocal()
Returns if locally produced messages are being inhibited.
Returns:
true if locally published messages are being inhibited.

receive

public MessageHandle receive(Condition cancel)
                      throws javax.jms.JMSException
Return the next available message to the client.
Parameters:
cancel - if set, indictates to cancel the receive
Returns:
the next message, or null if none is available
Throws:
javax.jms.JMSException - for any error

setAsynchronous

public void setAsynchronous(boolean asynchronous)
Indicates if this is an asynchronous consumer.

An asynchronous consumer has a client MessageConsumer with an associated MessageListener.

Parameters:
asynchronous - if true marks this as an asynchronous consumer

isAsynchronous

public boolean isAsynchronous()
Determines if this is an asynchronous consumer.
Returns:
true if this is an asynchronous consumer; otherwise false

setWaitingForMessage

public void setWaitingForMessage(Condition condition)
Indicates that the client is currently waiting for a message.
Parameters:
condition - the condition to evaluate to determine if the client is waiting for message. May be null.

isWaitingForMessage

public boolean isWaitingForMessage()
Determines if the client is currently waiting for a message.
Returns:
true if the client is waiting for messages; otherwise false

setListener

public void setListener(ConsumerEndpointListener listener)
Set the listener for this consumer. If a listener is set, it is notified when messages become available.
Parameters:
listener - the listener to add, or null to remove an existing listener

getMessageCount

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

isClosed

public boolean isClosed()
Determines if this consumer is closed, or in the process of being closed.
Returns:
true if this consumer is closed; otherwise false

close

public void close()
Close and release any resource allocated to this endpoint.

messageAdded

public boolean messageAdded(MessageHandle handle,
                            MessageImpl message)
                     throws javax.jms.JMSException
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
Throws:
javax.jms.JMSException - if the listener fails to handle the message

messageRemoved

public void messageRemoved(java.lang.String messageId)
                    throws javax.jms.JMSException
This event is called when a message is removed from the DestinationCache.
Parameters:
messageId - the identifier of the removed message
Throws:
javax.jms.JMSException - if the listener fails to handle the message

persistentMessageAdded

public boolean persistentMessageAdded(MessageHandle handle,
                                      MessageImpl message)
                               throws javax.jms.JMSException,
                                      PersistenceException
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 if the listener accepted the message;
Throws:
javax.jms.JMSException - if the listener fails to handle the message
PersistenceException - if there is a persistence related problem

persistentMessageRemoved

public void persistentMessageRemoved(java.lang.String messageId)
                              throws javax.jms.JMSException,
                                     PersistenceException
This event is called when a message is removed from the DestinationCache.
Parameters:
messageId - the identifier of the removed message
Throws:
javax.jms.JMSException - if the listener fails to handle the message
PersistenceException - if there is a persistence related problem


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