com.caucho.jms.cluster
Class ClusterQueueImpl<E extends java.io.Serializable>

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.cluster.ClusterQueueImpl<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:
ClusterQueue

public class ClusterQueueImpl<E extends java.io.Serializable>
extends AbstractQueue<E>

Implements a cluster receive queue.

See Also:
Serialized Form

Constructor Summary
ClusterQueueImpl()
           
ClusterQueueImpl(java.lang.String name)
           
 
Method Summary
 void acknowledge(java.lang.String msgId)
          Acknowledge receipt of the message.
 void addMessageCallback(MessageCallback<E> callback, boolean isAutoAck)
          Adds the callback to the listening list.
 void close()
           
 int getConsumerCount()
          Returns the number of active message consumers
protected  TriadOwner getQueueOwner(byte[] queueHash)
           
 int getQueueSize()
          Returns the queue size
 boolean hasMessage()
          Returns true if the queue has at least one message available
 boolean hasMessage(java.lang.String subscription)
           
 void init()
           
 boolean isBackup()
          Set true if messages should be backed up.
 E receive(long expireTime, boolean isAutoAck)
          Receives a message, blocking until expireTime if no message is available.
 E receive(long expireTime, boolean isAutoAck, QueueEntrySelector selector)
           
 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)
           
 void removeMessageCallback(MessageCallback<E> callback)
          Removes the callback from the listening list.
 void rollback(java.lang.String msgId)
          Rollback the message read.
 void send(java.lang.String msgId, E payload, int priority, long expires, java.lang.String publisherId)
          Sends a message to the queue
 void setBackup(boolean isBackup)
          Set true if messages should be backed up.
 void setCluster(java.lang.String cluster)
           
 
Methods inherited from class com.caucho.jms.queue.AbstractQueue
addListenerException, drainTo, drainTo, getBrowserList, getListenerFailCountTotal, getListenerFailLastTime, getReceiverCount, iterator, offer, offer, peek, poll, poll, postConstruct, put, 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, 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

ClusterQueueImpl

public ClusterQueueImpl()

ClusterQueueImpl

public ClusterQueueImpl(java.lang.String name)
Method Detail

setBackup

@Configurable
public void setBackup(boolean isBackup)
Set true if messages should be backed up.


isBackup

public boolean isBackup()
Set true if messages should be backed up.


setCluster

public void setCluster(java.lang.String cluster)

getQueueSize

public int getQueueSize()
Description copied from class: AbstractQueue
Returns the queue size

Overrides:
getQueueSize in class AbstractQueue<E extends java.io.Serializable>

getConsumerCount

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

Overrides:
getConsumerCount in class AbstractQueue<E extends java.io.Serializable>

init

@PostConstruct
public void init()
Overrides:
init in class AbstractQueue<E extends java.io.Serializable>

getQueueOwner

protected TriadOwner getQueueOwner(byte[] queueHash)

send

public void send(java.lang.String msgId,
                 E payload,
                 int priority,
                 long expires,
                 java.lang.String publisherId)
Description copied from class: AbstractDestination
Sends a message to the queue

Specified by:
send in interface MessageQueue<E extends java.io.Serializable>
Overrides:
send in class AbstractDestination<E extends java.io.Serializable>

receive

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

Specified by:
receive in interface MessageQueue<E extends java.io.Serializable>
Overrides:
receive in class AbstractQueue<E extends java.io.Serializable>

receive

public E receive(long expireTime,
                 boolean isAutoAck,
                 QueueEntrySelector selector)
Overrides:
receive in class AbstractQueue<E extends java.io.Serializable>

receiveEntry

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

Specified by:
receiveEntry in interface MessageQueue<E extends java.io.Serializable>
Overrides:
receiveEntry in class AbstractQueue<E extends java.io.Serializable>
Throws:
MessageException

receiveEntry

public QueueEntry<E> receiveEntry(long expireTime,
                                  boolean isAutoAck,
                                  QueueEntrySelector selector)
                                                        throws MessageException
Overrides:
receiveEntry in class AbstractQueue<E extends java.io.Serializable>
Throws:
MessageException

addMessageCallback

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

Specified by:
addMessageCallback in interface MessageQueue<E extends java.io.Serializable>
Overrides:
addMessageCallback in class AbstractQueue<E extends java.io.Serializable>
Throws:
MessageException

removeMessageCallback

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

Specified by:
removeMessageCallback in interface MessageQueue<E extends java.io.Serializable>
Overrides:
removeMessageCallback in class AbstractQueue<E extends java.io.Serializable>
Throws:
MessageException

rollback

public void rollback(java.lang.String msgId)
Description copied from class: AbstractQueue
Rollback the message read.

Specified by:
rollback in interface MessageQueue<E extends java.io.Serializable>
Overrides:
rollback in class AbstractQueue<E extends java.io.Serializable>

acknowledge

public void acknowledge(java.lang.String msgId)
Description copied from class: AbstractQueue
Acknowledge receipt of the message.

Specified by:
acknowledge in interface MessageQueue<E extends java.io.Serializable>
Overrides:
acknowledge in class AbstractQueue<E extends java.io.Serializable>
Parameters:
msgId - message to acknowledge

hasMessage

public boolean hasMessage()
Description copied from class: AbstractDestination
Returns true if the queue has at least one message available

Overrides:
hasMessage in class AbstractDestination<E extends java.io.Serializable>

hasMessage

public boolean hasMessage(java.lang.String subscription)

close

@PreDestroy
public void close()
Overrides:
close in class AbstractQueue<E extends java.io.Serializable>