com.caucho.jms.queue
Class AbstractQueue<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by com.caucho.jms.queue.AbstractDestination<E>
              extended by com.caucho.jms.queue.AbstractQueue<E>
All Implemented Interfaces:
HandleAware, MessageQueue<E>, java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.concurrent.BlockingQueue<E>, java.util.Queue<E>, Destination
Direct Known Subclasses:
AbstractMemoryQueue, ClusterQueueImpl, PollingQueue

public abstract class AbstractQueue<E>
extends AbstractDestination<E>
implements Queue, MessageQueue<E>, java.util.concurrent.BlockingQueue<E>

Implements an abstract queue.

See Also:
Serialized Form

Constructor Summary
protected AbstractQueue()
           
 
Method Summary
 void acknowledge(java.lang.String msgId)
          Acknowledge receipt of the message.
 void addListenerException(java.lang.Exception e)
          Called when a listener throws an excepton
 void addMessageCallback(MessageCallback<E> callback, boolean isAutoAck)
          Adds the callback to the listening list.
 void close()
           
 int drainTo(java.util.Collection<? super E> c)
           
 int drainTo(java.util.Collection<? super E> c, int max)
           
 java.util.ArrayList<? extends QueueEntry<E>> getBrowserList()
           
 int getConsumerCount()
          Returns the number of active message consumers
 long getListenerFailCountTotal()
          Returns the number of listener failures.
 long getListenerFailLastTime()
          Returns the number of listener failures.
 int getQueueSize()
          Returns the queue size
 int getReceiverCount()
          Returns the number of receivers.
protected  void init()
           
 java.util.Iterator<E> iterator()
           
 boolean offer(E message)
           
 boolean offer(E message, long timeout, java.util.concurrent.TimeUnit unit)
          Adds the item to the queue, waiting if necessary
 E peek()
           
 E poll()
           
 E poll(long timeout, java.util.concurrent.TimeUnit unit)
           
 void postConstruct()
           
 void put(E value)
           
 E receive(long expireTime, boolean isAutoAcknowledge)
          Receives a message, blocking until expireTime if no message is available.
 E receive(long expireTime, boolean isAutoAcknowledge, QueueEntrySelector selector)
           
 void receive(long expireTime, boolean isAutoAck, QueueEntrySelector selector, MessageCallback callback)
           
 QueueEntry<E> receiveEntry(long expireTime, boolean isAutoAck)
          Primary message receiving, registers a callback for any new message.
 QueueEntry<E> receiveEntry(long expireTime, boolean isAutoAck, QueueEntrySelector selector)
           
 int remainingCapacity()
           
 void removeMessageCallback(MessageCallback<E> entryCallback)
          Removes the callback from the listening list.
 void rollback(java.lang.String msgId)
          Rollback the message read.
 void setQueueName(java.lang.String name)
           
 int size()
           
 E take()
           
 
Methods inherited from class com.caucho.jms.queue.AbstractDestination
generateMessageID, generateMessageID, getJMSDestination, getName, getQueueName, getTopicName, getUrl, hasMessage, send, setName, setSerializationHandle, toString
 
Methods inherited from class java.util.AbstractQueue
add, addAll, clear, element, remove
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jms.Queue
getQueueName, toString
 
Methods inherited from interface com.caucho.jms.queue.MessageQueue
send
 
Methods inherited from interface java.util.concurrent.BlockingQueue
add, contains, remove
 
Methods inherited from interface java.util.Queue
element, remove
 
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Constructor Detail

AbstractQueue

protected AbstractQueue()
Method Detail

setQueueName

public void setQueueName(java.lang.String name)

init

protected void init()

postConstruct

@PostConstruct
public void postConstruct()

receiveEntry

public QueueEntry<E> receiveEntry(long expireTime,
                                  boolean isAutoAck)
Primary message receiving, registers a callback for any new message.

Specified by:
receiveEntry in interface MessageQueue<E>

receiveEntry

public QueueEntry<E> receiveEntry(long expireTime,
                                  boolean isAutoAck,
                                  QueueEntrySelector selector)
                           throws MessageException
Throws:
MessageException

receive

public void receive(long expireTime,
                    boolean isAutoAck,
                    QueueEntrySelector selector,
                    MessageCallback callback)
             throws MessageException
Throws:
MessageException

addMessageCallback

public void addMessageCallback(MessageCallback<E> callback,
                               boolean isAutoAck)
Adds the callback to the listening list.

Specified by:
addMessageCallback in interface MessageQueue<E>

removeMessageCallback

public void removeMessageCallback(MessageCallback<E> entryCallback)
Removes the callback from the listening list.

Specified by:
removeMessageCallback in interface MessageQueue<E>

acknowledge

public void acknowledge(java.lang.String msgId)
Acknowledge receipt of the message.

Specified by:
acknowledge in interface MessageQueue<E>
Overrides:
acknowledge in class AbstractDestination<E>
Parameters:
msgId - message to acknowledge

rollback

public void rollback(java.lang.String msgId)
Rollback the message read.

Specified by:
rollback in interface MessageQueue<E>
Overrides:
rollback in class AbstractDestination<E>

receive

public E receive(long expireTime,
                 boolean isAutoAcknowledge)
          throws MessageException
Receives a message, blocking until expireTime if no message is available.

Specified by:
receive in interface MessageQueue<E>
Throws:
MessageException

receive

public E receive(long expireTime,
                 boolean isAutoAcknowledge,
                 QueueEntrySelector selector)
          throws MessageException
Throws:
MessageException

getBrowserList

public java.util.ArrayList<? extends QueueEntry<E>> getBrowserList()

size

public int size()
Specified by:
size in interface java.util.Collection<E>
Specified by:
size in class java.util.AbstractCollection<E>

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in class java.util.AbstractCollection<E>

offer

public boolean offer(E message,
                     long timeout,
                     java.util.concurrent.TimeUnit unit)
Adds the item to the queue, waiting if necessary

Specified by:
offer in interface java.util.concurrent.BlockingQueue<E>

offer

public boolean offer(E message)
Specified by:
offer in interface java.util.concurrent.BlockingQueue<E>
Specified by:
offer in interface java.util.Queue<E>

put

public void put(E value)
Specified by:
put in interface java.util.concurrent.BlockingQueue<E>

poll

public E poll(long timeout,
              java.util.concurrent.TimeUnit unit)
Specified by:
poll in interface java.util.concurrent.BlockingQueue<E>

remainingCapacity

public int remainingCapacity()
Specified by:
remainingCapacity in interface java.util.concurrent.BlockingQueue<E>

peek

public E peek()
Specified by:
peek in interface java.util.Queue<E>

poll

public E poll()
Specified by:
poll in interface java.util.Queue<E>

take

public E take()
Specified by:
take in interface java.util.concurrent.BlockingQueue<E>

drainTo

public int drainTo(java.util.Collection<? super E> c)
Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<E>

drainTo

public int drainTo(java.util.Collection<? super E> c,
                   int max)
Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<E>

getConsumerCount

public int getConsumerCount()
Returns the number of active message consumers


getReceiverCount

public int getReceiverCount()
Returns the number of receivers.

Returns:

getQueueSize

public int getQueueSize()
Returns the queue size


getListenerFailCountTotal

public long getListenerFailCountTotal()
Returns the number of listener failures.


getListenerFailLastTime

public long getListenerFailLastTime()
Returns the number of listener failures.


addListenerException

public void addListenerException(java.lang.Exception e)
Called when a listener throws an excepton


close

@PreDestroy
public void close()
Overrides:
close in class AbstractDestination<E>