Class AbstractSubscription
- java.lang.Object
-
- 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
Fields Modifier and Type Field Description protected Brokerbrokerprotected ConnectionContextcontextprotected DestinationFilterdestinationFilterprotected CopyOnWriteArrayList<Destination>destinationsprotected ConsumerInfoinfoprotected AtomicIntegerprefetchExtension
-
Constructor Summary
Constructors Constructor Description AbstractSubscription(Broker broker, ConnectionContext context, ConsumerInfo info)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacknowledge(ConnectionContext context, MessageAck ack)Used when client acknowledge receipt of dispatched message.voidadd(ConnectionContext context, Destination destination)The subscription will be receiving messages from the destination.voidaddDestination(Destination destination)Add a destinationbooleanaddRecoveredMessage(ConnectionContext context, MessageReference message)Add a message to the SubscriptionRecoveryprotected voidcontractPrefetchExtension(int amount)intcountBeforeFull()protected voiddecrementPrefetchExtension(int amount)protected voiddoAddRecoveredMessage(MessageReference message)protected voidexpandPrefetchExtension(int amount)voidgc()The subscription should release as may references as it can to help the garbage collector reclaim memory.ActiveMQDestinationgetActiveMQDestination()longgetConsumedCount()ConsumerInfogetConsumerInfo()The ConsumerInfo object that created the subscription.ConnectionContextgetContext()intgetCursorMemoryHighWaterMark()CopyOnWriteArrayList<Destination>getDestinations()longgetInFlightMessageSize()intgetInFlightUsage()ConsumerInfogetInfo()ObjectNamegetObjectName()AtomicIntegergetPrefetchExtension()intgetPrefetchSize()StringgetSelector()BooleanExpressiongetSelectorExpression()SubscriptionStatisticsgetSubscriptionStatistics()longgetTimeOfLastMessageAck()Returns the time since the last Ack message was received by this subscription.voidincrementConsumedCount()booleanisBrowser()booleanisRecoveryRequired()Informs the Broker if the subscription needs to intervention to recover it's state e.g.booleanisSlowConsumer()booleanisUsePrefetchExtension()booleanisWildcard()Returns true if this subscription is a Wildcard subscription.booleanmatches(MessageReference node, MessageEvaluationContext context)Is the subscription interested in the message?booleanmatches(ActiveMQDestination destination)Is the subscription interested in messages in the destination?List<MessageReference>remove(ConnectionContext context, Destination destination)The subscription will be no longer be receiving messages from the destination.voidremoveDestination(Destination destination)Remove a destinationvoidresetConsumedCount()voidsetCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark)voidsetObjectName(ObjectName objectName)Set when the subscription is registered in JMXvoidsetPrefetchSize(int newSize)voidsetSelector(String selector)Attempts to change the current active selector on the subscription.voidsetSlowConsumer(boolean val)voidsetTimeOfLastMessageAck(long value)voidsetUsePrefetchExtension(boolean usePrefetchExtension)voidunmatched(MessageReference node)voidwakeupDestinationsForDispatch()-
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
add, destroy, getDequeueCounter, getDispatchedCounter, getDispatchedQueueSize, getEnqueueCounter, getInFlightSize, getPendingMessageSize, 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
-
prefetchExtension
protected final AtomicInteger prefetchExtension
-
-
Constructor Detail
-
AbstractSubscription
public AbstractSubscription(Broker broker, ConnectionContext context, ConsumerInfo info) throws InvalidSelectorException
- Throws:
InvalidSelectorException
-
-
Method Detail
-
acknowledge
public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception
Description copied from interface:SubscriptionUsed when client acknowledge receipt of dispatched message.- Specified by:
acknowledgein interfaceSubscription- Throws:
IOExceptionException
-
matches
public boolean matches(MessageReference node, MessageEvaluationContext context) throws IOException
Description copied from interface:SubscriptionIs the subscription interested in the message?- Specified by:
matchesin interfaceSubscription- Returns:
- true if matching
- Throws:
IOException
-
isWildcard
public boolean isWildcard()
Description copied from interface:SubscriptionReturns true if this subscription is a Wildcard subscription.- Specified by:
isWildcardin interfaceSubscription- Returns:
- true if wildcard subscription.
-
matches
public boolean matches(ActiveMQDestination destination)
Description copied from interface:SubscriptionIs the subscription interested in messages in the destination?- Specified by:
matchesin interfaceSubscription- Returns:
- true if matching
-
add
public void add(ConnectionContext context, Destination destination) throws Exception
Description copied from interface:SubscriptionThe subscription will be receiving messages from the destination.- Specified by:
addin interfaceSubscription- Throws:
Exception
-
remove
public List<MessageReference> remove(ConnectionContext context, Destination destination) throws Exception
Description copied from interface:SubscriptionThe subscription will be no longer be receiving messages from the destination.- Specified by:
removein interfaceSubscription- Returns:
- a list of un-acked messages that were added to the subscription.
- Throws:
Exception
-
getConsumerInfo
public ConsumerInfo getConsumerInfo()
Description copied from interface:SubscriptionThe ConsumerInfo object that created the subscription.- Specified by:
getConsumerInfoin interfaceSubscription
-
gc
public void gc()
Description copied from interface:SubscriptionThe subscription should release as may references as it can to help the garbage collector reclaim memory.- Specified by:
gcin interfaceSubscription
-
getContext
public ConnectionContext getContext()
- Specified by:
getContextin interfaceSubscription
-
getInfo
public ConsumerInfo getInfo()
-
getSelectorExpression
public BooleanExpression getSelectorExpression()
-
getSelector
public String getSelector()
- Specified by:
getSelectorin interfaceSubscription- Returns:
- the JMS selector on the current subscription
-
setSelector
public void setSelector(String selector) throws InvalidSelectorException
Description copied from interface:SubscriptionAttempts to change the current active selector on the subscription. This operation is not supported for persistent topics.- Specified by:
setSelectorin interfaceSubscription- Throws:
InvalidSelectorException
-
getObjectName
public ObjectName getObjectName()
- Specified by:
getObjectNamein interfaceSubscription- Returns:
- the JMX object name that this subscription was registered as if applicable
-
setObjectName
public void setObjectName(ObjectName objectName)
Description copied from interface:SubscriptionSet when the subscription is registered in JMX- Specified by:
setObjectNamein interfaceSubscription
-
getPrefetchSize
public int getPrefetchSize()
- Specified by:
getPrefetchSizein interfaceSubscription- Returns:
- the prefetch size that is configured for the subscription
-
isUsePrefetchExtension
public boolean isUsePrefetchExtension()
-
setUsePrefetchExtension
public void setUsePrefetchExtension(boolean usePrefetchExtension)
-
setPrefetchSize
public void setPrefetchSize(int newSize)
-
isRecoveryRequired
public boolean isRecoveryRequired()
Description copied from interface:SubscriptionInforms the Broker if the subscription needs to intervention to recover it's state e.g. DurableTopicSubscriber may do- Specified by:
isRecoveryRequiredin interfaceSubscription- Returns:
- true if recovery required
- See Also:
PendingMessageCursor
-
isSlowConsumer
public boolean isSlowConsumer()
- Specified by:
isSlowConsumerin interfaceSubscription
-
setSlowConsumer
public void setSlowConsumer(boolean val)
-
addRecoveredMessage
public boolean addRecoveredMessage(ConnectionContext context, MessageReference message) throws Exception
Description copied from interface:SubscriptionRecoveryAdd a message to the SubscriptionRecovery- Specified by:
addRecoveredMessagein interfaceSubscriptionRecovery- Returns:
- true if the message is accepted
- Throws:
Exception
-
getActiveMQDestination
public ActiveMQDestination getActiveMQDestination()
- Specified by:
getActiveMQDestinationin interfaceSubscriptionRecovery- Returns:
- the Destination associated with this Subscription
-
isBrowser
public boolean isBrowser()
- Specified by:
isBrowserin interfaceSubscription- Returns:
- true if a browser
-
getInFlightMessageSize
public long getInFlightMessageSize()
- Specified by:
getInFlightMessageSizein interfaceSubscription- Returns:
- the size in bytes of the messages awaiting acknowledgement
-
getInFlightUsage
public int getInFlightUsage()
- Specified by:
getInFlightUsagein interfaceSubscription- 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:
getCursorMemoryHighWaterMarkin interfaceSubscription
-
setCursorMemoryHighWaterMark
public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark)
- Specified by:
setCursorMemoryHighWaterMarkin interfaceSubscription
-
countBeforeFull
public int countBeforeFull()
- Specified by:
countBeforeFullin interfaceSubscription- Returns:
- the number of messages this subscription can accept before its full
-
unmatched
public void unmatched(MessageReference node) throws IOException
- Specified by:
unmatchedin interfaceSubscription- Throws:
IOException
-
doAddRecoveredMessage
protected void doAddRecoveredMessage(MessageReference message) throws Exception
- Throws:
Exception
-
getTimeOfLastMessageAck
public long getTimeOfLastMessageAck()
Description copied from interface:SubscriptionReturns the time since the last Ack message was received by this subscription. If there has never been an ack this value should be set to the creation time of the subscription.- Specified by:
getTimeOfLastMessageAckin interfaceSubscription- Returns:
- time of last received Ack message or Subscription create time if no Acks.
-
setTimeOfLastMessageAck
public void setTimeOfLastMessageAck(long value)
-
getConsumedCount
public long getConsumedCount()
- Specified by:
getConsumedCountin interfaceSubscription
-
incrementConsumedCount
public void incrementConsumedCount()
- Specified by:
incrementConsumedCountin interfaceSubscription
-
resetConsumedCount
public void resetConsumedCount()
- Specified by:
resetConsumedCountin interfaceSubscription
-
getSubscriptionStatistics
public SubscriptionStatistics getSubscriptionStatistics()
- Specified by:
getSubscriptionStatisticsin interfaceSubscription
-
wakeupDestinationsForDispatch
public void wakeupDestinationsForDispatch()
-
getPrefetchExtension
public AtomicInteger getPrefetchExtension()
-
contractPrefetchExtension
protected void contractPrefetchExtension(int amount)
-
expandPrefetchExtension
protected void expandPrefetchExtension(int amount)
-
decrementPrefetchExtension
protected void decrementPrefetchExtension(int amount)
-
getDestinations
public CopyOnWriteArrayList<Destination> getDestinations()
-
-