com.caucho.jms.queue
Class AbstractMemoryQueue<E,QE extends QueueEntry<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>
                  extended by com.caucho.jms.queue.AbstractMemoryQueue<E,QE>
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:
FileQueueImpl, MemoryQueueImpl

public abstract class AbstractMemoryQueue<E,QE extends QueueEntry<E>>
extends AbstractQueue<E>

Provides abstract implementation for a memory queue.

See Also:
Serialized Form

Constructor Summary
AbstractMemoryQueue()
           
 
Method Summary
protected  void acknowledge(QE entry)
           
 void acknowledge(java.lang.String msgId)
          Acknowledges the receipt of a message
 void addMessageCallback(MessageCallback<E> callback, boolean isAutoAck)
          Adds the callback to the listening list.
protected  void addQueueEntry(QE entry, long expires)
           
protected  void dispatchMessage()
           
 java.util.ArrayList<QE> getBrowserList()
           
 int getConsumerCount()
          Returns the number of active message consumers
 java.util.ArrayList<java.lang.String> getMessageIds()
           
 int getQueueSize()
          Returns the queue size
 int getQueueSizeMax()
           
 int getReceiverCount()
          Returns the number of receivers.
 boolean hasMessage()
          Returns true if a message is available.
protected  boolean listen(com.caucho.jms.queue.EntryCallback<E> callback)
           
protected  QE readEntry()
          Returns the next entry from the queue
protected  QE readEntry(QueueEntrySelector selector)
          Returns the next entry from the queue
protected  void readPayload(QE entry)
           
 void receive(long expireTime, boolean isAutoAck, QueueEntrySelector selector, MessageCallback callback)
           
 QE receiveEntry(long expireTime, boolean isAutoAck)
          Primary message receiving, registers a callback for any new message.
 QE receiveEntry(long expireTime, boolean isAutoAck, QueueEntrySelector selector)
           
protected  QE removeEntry(java.lang.String msgId)
          Removes message.
 void removeMessageCallback(MessageCallback<E> callback)
          Removes the callback from the listening list.
 void rollback(java.lang.String msgId)
          Rolls back the receipt of a message
 void send(java.lang.String msgId, E payload, int priority, long expireTime, java.lang.String publisherId)
          Sends a message to the queue
 void setQueueSizeMax(int max)
           
protected abstract  QE writeEntry(java.lang.String msg, E payload, int priority, long expires)
           
 
Methods inherited from class com.caucho.jms.queue.AbstractQueue
addListenerException, close, drainTo, drainTo, getListenerFailCountTotal, getListenerFailLastTime, init, iterator, offer, offer, peek, poll, poll, postConstruct, put, receive, receive, remainingCapacity, setQueueName, size, take
 
Methods inherited from class com.caucho.jms.queue.AbstractDestination
generateMessageID, generateMessageID, getJMSDestination, getName, getQueueName, getTopicName, getUrl, 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 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

AbstractMemoryQueue

public AbstractMemoryQueue()
Method Detail

setQueueSizeMax

public void setQueueSizeMax(int max)

getQueueSizeMax

public int getQueueSizeMax()

send

public void send(java.lang.String msgId,
                 E payload,
                 int priority,
                 long expireTime,
                 java.lang.String publisherId)
          throws MessageException
Sends a message to the queue

Specified by:
send in interface MessageQueue<E>
Overrides:
send in class AbstractDestination<E>
Throws:
MessageException

writeEntry

protected abstract QE writeEntry(java.lang.String msg,
                                 E payload,
                                 int priority,
                                 long expires)

addQueueEntry

protected void addQueueEntry(QE entry,
                             long expires)

receiveEntry

public QE receiveEntry(long expireTime,
                       boolean isAutoAck)
                                      throws MessageException
Primary message receiving, registers a callback for any new message.

Specified by:
receiveEntry in interface MessageQueue<E>
Overrides:
receiveEntry in class AbstractQueue<E>
Throws:
MessageException

receiveEntry

public QE receiveEntry(long expireTime,
                       boolean isAutoAck,
                       QueueEntrySelector selector)
                                      throws MessageException
Overrides:
receiveEntry in class AbstractQueue<E>
Throws:
MessageException

receive

public void receive(long expireTime,
                    boolean isAutoAck,
                    QueueEntrySelector selector,
                    MessageCallback callback)
             throws MessageException
Overrides:
receive in class AbstractQueue<E>
Throws:
MessageException

addMessageCallback

public void addMessageCallback(MessageCallback<E> callback,
                               boolean isAutoAck)
Description copied from class: AbstractQueue
Adds the callback to the listening list.

Specified by:
addMessageCallback in interface MessageQueue<E>
Overrides:
addMessageCallback in class AbstractQueue<E>

removeMessageCallback

public void removeMessageCallback(MessageCallback<E> callback)
Description copied from class: AbstractQueue
Removes the callback from the listening list.

Specified by:
removeMessageCallback in interface MessageQueue<E>
Overrides:
removeMessageCallback in class AbstractQueue<E>

acknowledge

protected void acknowledge(QE entry)

readPayload

protected void readPayload(QE entry)

acknowledge

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

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

listen

protected boolean listen(com.caucho.jms.queue.EntryCallback<E> callback)
                  throws MessageException
Throws:
MessageException

dispatchMessage

protected void dispatchMessage()

getQueueSize

public int getQueueSize()
Returns the queue size

Overrides:
getQueueSize in class AbstractQueue<E>

hasMessage

public boolean hasMessage()
Returns true if a message is available.

Overrides:
hasMessage in class AbstractDestination<E>

getConsumerCount

public int getConsumerCount()
Description copied from class: AbstractQueue
Returns the number of active message consumers

Overrides:
getConsumerCount in class AbstractQueue<E>

getReceiverCount

public int getReceiverCount()
Description copied from class: AbstractQueue
Returns the number of receivers.

Overrides:
getReceiverCount in class AbstractQueue<E>
Returns:

readEntry

protected QE readEntry()
Returns the next entry from the queue


readEntry

protected QE readEntry(QueueEntrySelector selector)
Returns the next entry from the queue


getBrowserList

public java.util.ArrayList<QE> getBrowserList()
Overrides:
getBrowserList in class AbstractQueue<E>
Parameters:
selector -
Returns:
Entries present in the Queue.

removeEntry

protected QE removeEntry(java.lang.String msgId)
Removes message.


rollback

public void rollback(java.lang.String msgId)
Rolls back the receipt of a message

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

getMessageIds

public java.util.ArrayList<java.lang.String> getMessageIds()