org.apache.activemq.broker.region
Class QueueSubscription

java.lang.Object
  extended by org.apache.activemq.broker.region.AbstractSubscription
      extended by org.apache.activemq.broker.region.PrefetchSubscription
          extended by org.apache.activemq.broker.region.QueueSubscription
All Implemented Interfaces:
LockOwner, Subscription
Direct Known Subclasses:
QueueBrowserSubscription

public class QueueSubscription
extends PrefetchSubscription
implements LockOwner


Field Summary
 
Fields inherited from class org.apache.activemq.broker.region.PrefetchSubscription
dispatched, pending, prefetchExtension
 
Fields inherited from class org.apache.activemq.broker.region.AbstractSubscription
broker, context, destinationFilter, destinations, info
 
Fields inherited from interface org.apache.activemq.broker.region.LockOwner
HIGH_PRIORITY_LOCK_OWNER
 
Constructor Summary
QueueSubscription(Broker broker, ConnectionContext context, ConsumerInfo info)
           
 
Method Summary
protected  void acknowledge(ConnectionContext context, MessageAck ack, MessageReference n)
          In the queue case, mark the node as dropped and then a gc cycle will remove it from the queue.
protected  void assignGroupToMe(MessageGroupMap messageGroupOwners, MessageReference n, java.lang.String groupId)
          Assigns the message group to this subscription and set the flag on the message that it is the first message to be dispatched.
protected  boolean canDispatch(MessageReference n)
          Use when a matched message is about to be dispatched to the client.
 void destroy()
          Called when the subscription is destroyed.
protected  boolean dispatch(MessageReference node)
          Override so that the message ref count is > 0 only when the message is being dispatched to a client.
 int getLockPriority()
           
 boolean isLockExclusive()
           
protected  void onDispatch(MessageReference node, Message message)
          OK Message was transmitted, we can now drop the reference count.
protected  void sendToDLQ(ConnectionContext context, MessageReference node)
          Sending a message to the DQL will require us to increment the ref count so we can get at the content.
 java.lang.String toString()
           
 
Methods inherited from class org.apache.activemq.broker.region.PrefetchSubscription
acknowledge, add, add, createMessageDispatch, dispatchMatched, getDequeueCounter, getDispatchedCounter, getDispatchedQueueSize, getEnqueueCounter, getPendingQueueSize, isFull, isHighWaterMark, isLowWaterMark, isRecoveryRequired, optimizePrefetch, processMessageDispatchNotification, pullMessage, remove, updateConsumerPrefetch
 
Methods inherited from class org.apache.activemq.broker.region.AbstractSubscription
gc, getConsumerInfo, getContext, getInfo, getObjectName, getPrefetchSize, getSelector, getSelectorExpression, isSlaveBroker, matches, matches, setObjectName, setSelector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueueSubscription

public QueueSubscription(Broker broker,
                         ConnectionContext context,
                         ConsumerInfo info)
                  throws javax.jms.InvalidSelectorException
Throws:
javax.jms.InvalidSelectorException
Method Detail

acknowledge

protected void acknowledge(ConnectionContext context,
                           MessageAck ack,
                           MessageReference n)
                    throws java.io.IOException
In the queue case, mark the node as dropped and then a gc cycle will remove it from the queue.

Overrides:
acknowledge in class PrefetchSubscription
Throws:
java.io.IOException

canDispatch

protected boolean canDispatch(MessageReference n)
                       throws java.io.IOException
Description copied from class: PrefetchSubscription
Use when a matched message is about to be dispatched to the client.

Specified by:
canDispatch in class PrefetchSubscription
Returns:
false if the message should not be dispatched to the client (another sub may have already dispatched it for example).
Throws:
java.io.IOException

assignGroupToMe

protected void assignGroupToMe(MessageGroupMap messageGroupOwners,
                               MessageReference n,
                               java.lang.String groupId)
                        throws java.io.IOException
Assigns the message group to this subscription and set the flag on the message that it is the first message to be dispatched.

Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getLockPriority

public int getLockPriority()
Specified by:
getLockPriority in interface LockOwner

isLockExclusive

public boolean isLockExclusive()
Specified by:
isLockExclusive in interface LockOwner

dispatch

protected boolean dispatch(MessageReference node)
                    throws java.io.IOException
Override so that the message ref count is > 0 only when the message is being dispatched to a client. Keeping it at 0 when it is in the pending list allows the message to be swapped out to disk.

Overrides:
dispatch in class PrefetchSubscription
Returns:
true if the message was dispatched.
Throws:
java.io.IOException

onDispatch

protected void onDispatch(MessageReference node,
                          Message message)
OK Message was transmitted, we can now drop the reference count.

Overrides:
onDispatch in class PrefetchSubscription
See Also:
PrefetchSubscription.onDispatch(org.apache.activemq.broker.region.MessageReference, org.apache.activemq.command.Message)

sendToDLQ

protected void sendToDLQ(ConnectionContext context,
                         MessageReference node)
                  throws java.io.IOException,
                         java.lang.Exception
Sending a message to the DQL will require us to increment the ref count so we can get at the content.

Overrides:
sendToDLQ in class PrefetchSubscription
Throws:
java.io.IOException
java.lang.Exception

destroy

public void destroy()
Description copied from interface: Subscription
Called when the subscription is destroyed.

Specified by:
destroy in interface Subscription


Copyright © 2010 Apache Software Foundation. All Rights Reserved.