org.apache.activemq.broker.region
Class TopicSubscription

java.lang.Object
  extended by org.apache.activemq.broker.region.AbstractSubscription
      extended by org.apache.activemq.broker.region.TopicSubscription
All Implemented Interfaces:
Subscription

public class TopicSubscription
extends AbstractSubscription


Field Summary
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong dispatchedCounter
           
protected  ActiveMQDestination dlqDestination
           
protected  LinkedList matched
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong prefetchExtension
           
protected  UsageManager usageManager
           
 
Fields inherited from class org.apache.activemq.broker.region.AbstractSubscription
broker, context, destinationFilter, destinations, info
 
Constructor Summary
TopicSubscription(Broker broker, ConnectionContext context, ConsumerInfo info, UsageManager usageManager)
           
 
Method Summary
 void acknowledge(ConnectionContext context, MessageAck ack)
          Used when client acknowledge receipt of dispatched message.
 void add(MessageReference node)
          Used to add messages that match the subscription.
 void destroy()
          Called when the subscription is destroyed.
 int discarded()
           
 long getDequeueCounter()
           
 long getDispatchedCounter()
           
 int getDispatchedQueueSize()
           
 long getEnqueueCounter()
           
 int getMaximumPendingMessages()
           
 MessageEvictionStrategy getMessageEvictionStrategy()
           
 int getPendingQueueSize()
           
 int getPrefetchSize()
           
 boolean isHighWaterMark()
           
 boolean isLowWaterMark()
           
 int matched()
           
 void optimizePrefetch()
          optimize message consumer prefetch if the consumer supports it
 void processMessageDispatchNotification(MessageDispatchNotification mdn)
          Used by a Slave Broker to update dispatch infomation
 Response pullMessage(ConnectionContext context, MessagePull pull)
          Allows a consumer to pull a message on demand
protected  void removeExpiredMessages(LinkedList messages)
          Discard any expired messages from the matched list.
 void setMaximumPendingMessages(int maximumPendingMessages)
          Sets the maximum number of pending messages that can be matched against this consumer before old messages are discarded.
 void setMessageEvictionStrategy(MessageEvictionStrategy messageEvictionStrategy)
          Sets the eviction strategy used to decide which message to evict when the slow consumer needs to discard messages
 String toString()
           
 void updateConsumerPrefetch(int newPrefetch)
          inform the MessageConsumer on the client to change it's prefetch
 
Methods inherited from class org.apache.activemq.broker.region.AbstractSubscription
add, gc, getConsumerInfo, getContext, getInfo, getObjectName, getSelector, getSelectorExpression, isRecoveryRequired, isSlaveBroker, matches, matches, remove, setObjectName, setSelector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

matched

protected final LinkedList matched

dlqDestination

protected final ActiveMQDestination dlqDestination

usageManager

protected final UsageManager usageManager

dispatchedCounter

protected edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong dispatchedCounter

prefetchExtension

protected edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong prefetchExtension
Constructor Detail

TopicSubscription

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

add

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

Throws:
InterruptedException
IOException

removeExpiredMessages

protected void removeExpiredMessages(LinkedList messages)
                              throws IOException
Discard any expired messages from the matched list. Called from a synchronized block.

Throws:
IOException

processMessageDispatchNotification

public void processMessageDispatchNotification(MessageDispatchNotification mdn)
Description copied from interface: Subscription
Used by a Slave Broker to update dispatch infomation


acknowledge

public void acknowledge(ConnectionContext context,
                        MessageAck ack)
                 throws Exception
Description copied from interface: Subscription
Used when client acknowledge receipt of dispatched message.

Throws:
IOException
Exception

pullMessage

public Response pullMessage(ConnectionContext context,
                            MessagePull pull)
                     throws Exception
Description copied from interface: Subscription
Allows a consumer to pull a message on demand

Throws:
Exception

getPendingQueueSize

public int getPendingQueueSize()
Returns:
number of messages pending delivery

getDispatchedQueueSize

public int getDispatchedQueueSize()
Returns:
number of messages dispatched to the client

getMaximumPendingMessages

public int getMaximumPendingMessages()

getDispatchedCounter

public long getDispatchedCounter()
Returns:
number of messages dispatched to the client

getEnqueueCounter

public long getEnqueueCounter()
Returns:
number of messages that matched the subscription

getDequeueCounter

public long getDequeueCounter()
Returns:
number of messages queued by the client

discarded

public int discarded()
Returns:
the number of messages discarded due to being a slow consumer

matched

public int matched()
Returns:
the number of matched messages (messages targeted for the subscription but not yet able to be dispatched due to the prefetch buffer being full).

setMaximumPendingMessages

public void setMaximumPendingMessages(int maximumPendingMessages)
Sets the maximum number of pending messages that can be matched against this consumer before old messages are discarded.


getMessageEvictionStrategy

public MessageEvictionStrategy getMessageEvictionStrategy()

setMessageEvictionStrategy

public void setMessageEvictionStrategy(MessageEvictionStrategy messageEvictionStrategy)
Sets the eviction strategy used to decide which message to evict when the slow consumer needs to discard messages


isLowWaterMark

public boolean isLowWaterMark()
Returns:
true when 60% or more room is left for dispatching messages

isHighWaterMark

public boolean isHighWaterMark()
Returns:
true when 10% or less room is left for dispatching messages

updateConsumerPrefetch

public void updateConsumerPrefetch(int newPrefetch)
inform the MessageConsumer on the client to change it's prefetch

Parameters:
newPrefetch -

optimizePrefetch

public void optimizePrefetch()
optimize message consumer prefetch if the consumer supports it


toString

public String toString()
Overrides:
toString in class Object

destroy

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


getPrefetchSize

public int getPrefetchSize()
Specified by:
getPrefetchSize in interface Subscription
Overrides:
getPrefetchSize in class AbstractSubscription
Returns:
the prefetch size that is configured for the subscription


Copyright © 2011 Apache Software Foundation. All Rights Reserved.