org.apache.activemq.broker.region
Class AbstractSubscription

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

public abstract class AbstractSubscription
extends Object
implements Subscription


Field Summary
protected  Broker broker
           
protected  ConnectionContext context
           
protected  DestinationFilter destinationFilter
           
protected  CopyOnWriteArrayList<Destination> destinations
           
protected  ConsumerInfo info
           
 
Constructor Summary
AbstractSubscription(Broker broker, ConnectionContext context, ConsumerInfo info)
           
 
Method Summary
 void add(ConnectionContext context, Destination destination)
          The subscription will be receiving messages from the destination.
 void addDestination(Destination destination)
          Add a destination
 boolean addRecoveredMessage(ConnectionContext context, MessageReference message)
          Add a message to the SubscriptionRecovery
 int countBeforeFull()
           
protected  void doAddRecoveredMessage(MessageReference message)
           
 void gc()
          The subscription should release as may references as it can to help the garbage collector reclaim memory.
 ActiveMQDestination getActiveMQDestination()
           
 ConsumerInfo getConsumerInfo()
          The ConsumerInfo object that created the subscription.
 ConnectionContext getContext()
           
 int getCursorMemoryHighWaterMark()
           
 int getInFlightUsage()
           
 ConsumerInfo getInfo()
           
 ObjectName getObjectName()
           
 int getPrefetchSize()
           
 String getSelector()
           
 BooleanExpression getSelectorExpression()
           
 boolean isBrowser()
           
 boolean isRecoveryRequired()
          Informs the Broker if the subscription needs to intervention to recover it's state e.g.
 boolean isSlave()
           
 boolean isSlowConsumer()
           
 boolean matches(ActiveMQDestination destination)
          Is the subscription interested in messages in the destination?
 boolean matches(MessageReference node, MessageEvaluationContext context)
          Is the subscription interested in the message?
 List<MessageReference> remove(ConnectionContext context, Destination destination)
          The subscription will be no longer be receiving messages from the destination.
 void removeDestination(Destination destination)
          Remove a destination
 void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark)
           
 void setObjectName(ObjectName objectName)
          Set when the subscription is registered in JMX
 void setPrefetchSize(int newSize)
           
 void setSelector(String selector)
          Attempts to change the current active selector on the subscription.
 void setSlowConsumer(boolean val)
           
 void unmatched(MessageReference node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.activemq.broker.region.Subscription
acknowledge, add, destroy, getDequeueCounter, getDispatchedCounter, getDispatchedQueueSize, getEnqueueCounter, getInFlightSize, getPendingQueueSize, isFull, isHighWaterMark, isLowWaterMark, processMessageDispatchNotification, pullMessage, updateConsumerPrefetch
 

Field Detail

broker

protected Broker broker

context

protected ConnectionContext context

info

protected ConsumerInfo info

destinationFilter

protected final DestinationFilter destinationFilter

destinations

protected final CopyOnWriteArrayList<Destination> destinations
Constructor Detail

AbstractSubscription

public AbstractSubscription(Broker broker,
                            ConnectionContext context,
                            ConsumerInfo info)
                     throws InvalidSelectorException
Throws:
InvalidSelectorException
Method Detail

matches

public boolean matches(MessageReference node,
                       MessageEvaluationContext context)
                throws IOException
Description copied from interface: Subscription
Is the subscription interested in the message?

Specified by:
matches in interface Subscription
Returns:
Throws:
IOException

matches

public boolean matches(ActiveMQDestination destination)
Description copied from interface: Subscription
Is the subscription interested in messages in the destination?

Specified by:
matches in interface Subscription
Returns:

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
Throws:
Exception

remove

public List<MessageReference> remove(ConnectionContext context,
                                     Destination destination)
                              throws Exception
Description copied from interface: Subscription
The subscription will be no longer be receiving messages from the destination.

Specified by:
remove in interface Subscription
Returns:
a list of un-acked messages that were added to the subscription.
Throws:
Exception

getConsumerInfo

public ConsumerInfo getConsumerInfo()
Description copied from interface: Subscription
The ConsumerInfo object that created the subscription.

Specified by:
getConsumerInfo in interface Subscription

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

isSlave

public boolean isSlave()
Specified by:
isSlave in interface Subscription
Returns:
true if the broker is currently in slave mode

getContext

public ConnectionContext getContext()
Specified by:
getContext in interface Subscription

getInfo

public ConsumerInfo getInfo()

getSelectorExpression

public BooleanExpression getSelectorExpression()

getSelector

public String getSelector()
Specified by:
getSelector in interface Subscription
Returns:
the JMS selector on the current subscription

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
Throws:
InvalidSelectorException

getObjectName

public ObjectName getObjectName()
Specified by:
getObjectName in interface Subscription
Returns:
the JMX object name that this subscription was registered as if applicable

setObjectName

public void setObjectName(ObjectName objectName)
Description copied from interface: Subscription
Set when the subscription is registered in JMX

Specified by:
setObjectName in interface Subscription

getPrefetchSize

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

setPrefetchSize

public void setPrefetchSize(int newSize)

isRecoveryRequired

public boolean isRecoveryRequired()
Description copied from interface: Subscription
Informs the Broker if the subscription needs to intervention to recover it's state e.g. DurableTopicSubscriber may do

Specified by:
isRecoveryRequired in interface Subscription
Returns:
true if recovery required
See Also:
org.apache.activemq.region.cursors.PendingMessageCursor

isSlowConsumer

public boolean isSlowConsumer()
Specified by:
isSlowConsumer in interface Subscription

setSlowConsumer

public void setSlowConsumer(boolean val)

addRecoveredMessage

public boolean addRecoveredMessage(ConnectionContext context,
                                   MessageReference message)
                            throws Exception
Description copied from interface: SubscriptionRecovery
Add a message to the SubscriptionRecovery

Specified by:
addRecoveredMessage in interface SubscriptionRecovery
Returns:
true if the message is accepted
Throws:
Exception

getActiveMQDestination

public ActiveMQDestination getActiveMQDestination()
Specified by:
getActiveMQDestination in interface SubscriptionRecovery
Returns:
the Destination associated with this Subscription

isBrowser

public boolean isBrowser()
Specified by:
isBrowser in interface Subscription
Returns:
true if a browser

getInFlightUsage

public int getInFlightUsage()
Specified by:
getInFlightUsage in interface Subscription
Returns:
the in flight messages as a percentage of the prefetch size

addDestination

public void addDestination(Destination destination)
Add a destination

Parameters:
destination -

removeDestination

public void removeDestination(Destination destination)
Remove a destination

Parameters:
destination -

getCursorMemoryHighWaterMark

public int getCursorMemoryHighWaterMark()
Specified by:
getCursorMemoryHighWaterMark in interface Subscription

setCursorMemoryHighWaterMark

public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark)
Specified by:
setCursorMemoryHighWaterMark in interface Subscription

countBeforeFull

public int countBeforeFull()
Specified by:
countBeforeFull in interface Subscription
Returns:
the number of messages this subscription can accept before its full

unmatched

public void unmatched(MessageReference node)
               throws IOException
Specified by:
unmatched in interface Subscription
Throws:
IOException

doAddRecoveredMessage

protected void doAddRecoveredMessage(MessageReference message)
                              throws Exception
Throws:
Exception


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