jrun.jms.core.messagemgr
Class QueueConsumerEndpoint

java.lang.Object
  |
  +--jrun.jms.core.messagemgr.ConsumerEndpoint
        |
        +--jrun.jms.core.messagemgr.QueueConsumerEndpoint
All Implemented Interfaces:
DestinationCacheEventListener, Identifiable, java.lang.Runnable, java.io.Serializable

public class QueueConsumerEndpoint
extends ConsumerEndpoint

A QueueConsumerEndpoint extends ConsumerEndpoint. This object shares access to a particular Queue with other QueueConsumerEndpoint instances.

Version:
$Revision: 1.18 $ $Date: 2001/09/18 10:50:34 $
Author:
Jim Alateras
See Also:
Serialized Form

Fields inherited from class jrun.jms.core.messagemgr.ConsumerEndpoint
_ackMode, _connectionId, _destroyed, _listener, _messages, _nolocal, _scheduled, _scheduler, _selector, _session, _size, _stopped, _transacted
 
Method Summary
 boolean canGarbageCollect(MessageHandle handle)
          Always return true since this endpoint does not hold any objects.
 void destroy()
          Destroy this object
 JmsDestination getDestination()
          Return the destination that this consumer is subscribed too
 boolean hasMessageListener()
          Check whether a listener has been registered with this endpoint to support async message delivery
 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.
 MessageHandle receiveMessage()
          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.
 void run()
          The run method is used to asynchronously deliver the messages in the cache to the consumer.
protected  void schedule()
          Schedule asynchronouse message delivery
 void setMessageListener(InternalMessageListener listener)
          Set the message listener for this consmer.
 void stopMessageDelivery()
          Stop delivering messages to the registered listener
 void unregister()
          Unregister this consumer for the specified destination cache, so that it will stop receiving messages from it.
 
Methods inherited from class jrun.jms.core.messagemgr.ConsumerEndpoint
clearMessages, getAckMode, getClientId, getConnectionId, getId, getIdAsString, getLogger, getMaximumSize, getMessageCount, getNoLocal, getSelector, getSession, getTransacted, getUnprocessedMessageCount, getUnsentMessages, hashCode, persistentMessageAdded, persistentMessageRemoved, setAckMode, setCacheEvictionPolicy, setClientId, setConnectionId, setMaximumSize, setNoLocal, setSelector, setStopped, setTransacted, shutdown, startMessageDelivery, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

run

public void run()
The run method is used to asynchronously deliver the messages in the cache to the consumer. It is scheduler by the Scheduler.

The thread, assigned by the scheduler, will attempt to deliver all the messages in the cache and then terminate. In addition this method must be prepared to be interrupted.


setMessageListener

public void setMessageListener(InternalMessageListener listener)
Description copied from class: ConsumerEndpoint
Set the message listener for this consmer. If a message listener is set then messages will be scheduled to be sent to it when they are available

Each consumer cache can only have a single message listener. To remove the message listener call this method with null argument

Overrides:
setMessageListener in class ConsumerEndpoint
Following copied from class: jrun.jms.core.messagemgr.ConsumerEndpoint
Parameters:
listener - - the message listener to add.

receiveMessage

public MessageHandle receiveMessage()
Description copied from class: ConsumerEndpoint
Return the next message to the client. This will also mark the message as sent and move it to the sent queue
Overrides:
receiveMessage in class ConsumerEndpoint
Following copied from class: jrun.jms.core.messagemgr.ConsumerEndpoint
Returns:
MessageHandle - handle to the next message in the list

canGarbageCollect

public boolean canGarbageCollect(MessageHandle handle)
Always return true since this endpoint does not hold any objects.
Overrides:
canGarbageCollect in class ConsumerEndpoint
Parameters:
handle - - message to check
Returns:
boolean - true if we can garbage collect

hasMessageListener

public boolean hasMessageListener()
Check whether a listener has been registered with this endpoint to support async message delivery
Returns:
boolean - true if it has

unregister

public void unregister()
Description copied from class: ConsumerEndpoint
Unregister this consumer for the specified destination cache, so that it will stop receiving messages from it.
Overrides:
unregister in class ConsumerEndpoint

getDestination

public JmsDestination getDestination()
Description copied from class: ConsumerEndpoint
Return the destination that this consumer is subscribed too
Overrides:
getDestination in class ConsumerEndpoint
Following copied from class: jrun.jms.core.messagemgr.ConsumerEndpoint
Returns:
JmsDestination

messageAdded

public boolean messageAdded(MessageImpl message)
Description copied from interface: DestinationCacheEventListener
This event is called when a non-persistent message is added to the DestinationCache.
Overrides:
messageAdded in class ConsumerEndpoint
Following copied from interface: jrun.jms.core.messagemgr.DestinationCacheEventListener
Parameters:
message - - message added to cache

messageRemoved

public boolean messageRemoved(MessageImpl message)
Description copied from interface: DestinationCacheEventListener
This event is called when a message is removed from the DestinationCache.
Overrides:
messageRemoved in class ConsumerEndpoint
Following copied from interface: jrun.jms.core.messagemgr.DestinationCacheEventListener
Parameters:
message - - message removed from cache

destroy

public void destroy()
Destroy this object
Overrides:
destroy in class ConsumerEndpoint

stopMessageDelivery

public void stopMessageDelivery()
Description copied from class: ConsumerEndpoint
Stop delivering messages to the registered listener
Overrides:
stopMessageDelivery in class ConsumerEndpoint

schedule

protected void schedule()
Description copied from class: ConsumerEndpoint
Schedule asynchronouse message delivery
Overrides:
schedule in class ConsumerEndpoint

recover

public void recover()
Description copied from class: ConsumerEndpoint
This message will return all unacked messages to the queue and allow them to be resent to the consumer with the redelivery flag on.
Overrides:
recover in class ConsumerEndpoint


Copyright � 2002 Macromedia Corporation. All Rights Reserved.