org.apache.activemq.broker.region
Class DurableTopicSubscription

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.DurableTopicSubscription
All Implemented Interfaces:
Subscription, SubscriptionRecovery, UsageListener

public class DurableTopicSubscription
extends PrefetchSubscription
implements UsageListener


Field Summary
 
Fields inherited from class org.apache.activemq.broker.region.PrefetchSubscription
dequeueCounter, dispatchCounter, dispatched, dispatchLock, enqueueCounter, pending, pendingLock, prefetchExtension, scheduler, usageManager, usePrefetchExtension
 
Fields inherited from class org.apache.activemq.broker.region.AbstractSubscription
broker, context, destinationFilter, destinations, info
 
Constructor Summary
DurableTopicSubscription(Broker broker, SystemUsage usageManager, ConnectionContext context, ConsumerInfo info, boolean keepDurableSubsActive)
           
 
Method Summary
protected  void acknowledge(ConnectionContext context, MessageAck ack, MessageReference node)
          Used during acknowledgment to remove the message.
 void activate(SystemUsage memoryManager, ConnectionContext context, ConsumerInfo info, RegionBroker regionBroker)
           
 void add(ConnectionContext context, Destination destination)
          The subscription will be receiving messages from the destination.
 void add(MessageReference node)
          Used to add messages that match the subscription.
protected  boolean canDispatch(MessageReference node)
          Use when a matched message is about to be dispatched to the client.
protected  MessageDispatch createMessageDispatch(MessageReference node, Message message)
           
 void deactivate(boolean keepDurableSubsActive)
           
 void destroy()
          Release any references that we are holding.
protected  void dispatchPending()
           
protected  void doAddRecoveredMessage(MessageReference message)
           
 void gc()
          The subscription should release as may references as it can to help the garbage collector reclaim memory.
 long getOfflineTimestamp()
           
 int getPendingQueueSize()
           
 SubscriptionKey getSubscriptionKey()
           
 boolean isActive()
           
protected  boolean isDropped(MessageReference node)
           
 boolean isFull()
          Used to determine if the broker can dispatch to the consumer.
 boolean isKeepDurableSubsActive()
           
 void onUsageChanged(Usage usage, int oldPercentUsage, int newPercentUsage)
           
 void removePending(MessageReference node)
           
 void setOfflineTimestamp(long timestamp)
           
protected  void setPendingBatchSize(PendingMessageCursor pending, int numberToDispatch)
           
 void setSelector(String selector)
          Attempts to change the current active selector on the subscription.
 String toString()
           
 void unmatched(MessageReference node)
          store will have a pending ack for all durables, irrespective of the selector so we need to ack if node is un-matched
 
Methods inherited from class org.apache.activemq.broker.region.PrefetchSubscription
acknowledge, assertAckMatchesDispatched, countBeforeFull, dispatch, getDequeueCounter, getDispatchedCounter, getDispatchedQueueSize, getEnqueueCounter, getInFlightSize, getMaxAuditDepth, getMaxProducersToAudit, getPending, getPrefetchExtension, isHighWaterMark, isLowWaterMark, isRecoveryRequired, isUsePrefetchExtension, onDispatch, processMessageDispatchNotification, pullMessage, remove, sendToDLQ, setMaxAuditDepth, setMaxProducersToAudit, setPending, setPrefetchSize, setUsePrefetchExtension, updateConsumerPrefetch
 
Methods inherited from class org.apache.activemq.broker.region.AbstractSubscription
addDestination, addRecoveredMessage, getActiveMQDestination, getConsumerInfo, getContext, getCursorMemoryHighWaterMark, getInFlightUsage, getInfo, getObjectName, getPrefetchSize, getSelector, getSelectorExpression, isBrowser, isSlowConsumer, matches, matches, removeDestination, setCursorMemoryHighWaterMark, setObjectName, setSlowConsumer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DurableTopicSubscription

public DurableTopicSubscription(Broker broker,
                                SystemUsage usageManager,
                                ConnectionContext context,
                                ConsumerInfo info,
                                boolean keepDurableSubsActive)
                         throws JMSException
Throws:
JMSException
Method Detail

isActive

public final boolean isActive()

getOfflineTimestamp

public final long getOfflineTimestamp()

setOfflineTimestamp

public void setOfflineTimestamp(long timestamp)

isFull

public boolean isFull()
Description copied from class: PrefetchSubscription
Used to determine if the broker can dispatch to the consumer.

Specified by:
isFull in interface Subscription
Overrides:
isFull in class PrefetchSubscription
Returns:
true if there is no space to dispatch messages

gc

public void gc()
Description copied from interface: Subscription
The subscription should release as may references as it can to help the garbage collector reclaim memory.

Specified by:
gc in interface Subscription
Overrides:
gc in class AbstractSubscription

unmatched

public void unmatched(MessageReference node)
               throws IOException
store will have a pending ack for all durables, irrespective of the selector so we need to ack if node is un-matched

Specified by:
unmatched in interface Subscription
Overrides:
unmatched in class AbstractSubscription
Throws:
IOException

setPendingBatchSize

protected void setPendingBatchSize(PendingMessageCursor pending,
                                   int numberToDispatch)
Overrides:
setPendingBatchSize in class PrefetchSubscription

add

public void add(ConnectionContext context,
                Destination destination)
         throws Exception
Description copied from interface: Subscription
The subscription will be receiving messages from the destination.

Specified by:
add in interface Subscription
Overrides:
add in class PrefetchSubscription
Throws:
Exception

activate

public void activate(SystemUsage memoryManager,
                     ConnectionContext context,
                     ConsumerInfo info,
                     RegionBroker regionBroker)
              throws Exception
Throws:
Exception

deactivate

public void deactivate(boolean keepDurableSubsActive)
                throws Exception
Throws:
Exception

createMessageDispatch

protected MessageDispatch createMessageDispatch(MessageReference node,
                                                Message message)
Overrides:
createMessageDispatch in class PrefetchSubscription
Returns:
MessageDispatch

add

public void add(MessageReference node)
         throws Exception
Description copied from interface: Subscription
Used to add messages that match the subscription.

Specified by:
add in interface Subscription
Overrides:
add in class PrefetchSubscription
Throws:
Exception
InterruptedException
IOException

dispatchPending

protected void dispatchPending()
                        throws IOException
Overrides:
dispatchPending in class PrefetchSubscription
Throws:
IOException

removePending

public void removePending(MessageReference node)
                   throws IOException
Throws:
IOException

doAddRecoveredMessage

protected void doAddRecoveredMessage(MessageReference message)
                              throws Exception
Overrides:
doAddRecoveredMessage in class AbstractSubscription
Throws:
Exception

getPendingQueueSize

public int getPendingQueueSize()
Specified by:
getPendingQueueSize in interface Subscription
Overrides:
getPendingQueueSize in class PrefetchSubscription
Returns:
number of messages pending delivery

setSelector

public void setSelector(String selector)
                 throws InvalidSelectorException
Description copied from interface: Subscription
Attempts to change the current active selector on the subscription. This operation is not supported for persistent topics.

Specified by:
setSelector in interface Subscription
Overrides:
setSelector in class AbstractSubscription
Throws:
InvalidSelectorException

canDispatch

protected boolean canDispatch(MessageReference node)
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).

acknowledge

protected void acknowledge(ConnectionContext context,
                           MessageAck ack,
                           MessageReference node)
                    throws IOException
Description copied from class: PrefetchSubscription
Used during acknowledgment to remove the message.

Specified by:
acknowledge in class PrefetchSubscription
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

getSubscriptionKey

public SubscriptionKey getSubscriptionKey()

destroy

public void destroy()
Release any references that we are holding.

Specified by:
destroy in interface Subscription

onUsageChanged

public void onUsageChanged(Usage usage,
                           int oldPercentUsage,
                           int newPercentUsage)
Specified by:
onUsageChanged in interface UsageListener

isDropped

protected boolean isDropped(MessageReference node)
Specified by:
isDropped in class PrefetchSubscription

isKeepDurableSubsActive

public boolean isKeepDurableSubsActive()


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.