Class AbstractSubscription
java.lang.Object
org.apache.activemq.broker.region.AbstractSubscription
- All Implemented Interfaces:
Subscription,SubscriptionRecovery
- Direct Known Subclasses:
PrefetchSubscription,TopicSubscription
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Brokerprotected ConnectionContextprotected final org.apache.activemq.filter.DestinationFilterprotected final CopyOnWriteArrayList<Destination>protected org.apache.activemq.command.ConsumerInfoprotected final AtomicInteger -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSubscription(Broker broker, ConnectionContext context, org.apache.activemq.command.ConsumerInfo info) -
Method Summary
Modifier and TypeMethodDescriptionvoidacknowledge(ConnectionContext context, org.apache.activemq.command.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, org.apache.activemq.broker.region.MessageReference message) Add a message to the SubscriptionRecoveryprotected voidcontractPrefetchExtension(int amount) intprotected voiddecrementPrefetchExtension(int amount) protected voiddoAddRecoveredMessage(org.apache.activemq.broker.region.MessageReference message) protected voidexpandPrefetchExtension(int amount) voidgc()The subscription should release as may references as it can to help the garbage collector reclaim memory.org.apache.activemq.command.ActiveMQDestinationlongorg.apache.activemq.command.ConsumerInfoThe ConsumerInfo object that created the subscription.intlongintorg.apache.activemq.command.ConsumerInfogetInfo()intorg.apache.activemq.filter.BooleanExpressionlongReturns the time since the last Ack message was received by this subscription.voidbooleanbooleanInforms the Broker if the subscription needs to intervention to recover it's state e.g.booleanbooleanbooleanReturns true if this subscription is a Wildcard subscription.booleanmatches(org.apache.activemq.broker.region.MessageReference node, org.apache.activemq.filter.MessageEvaluationContext context) Is the subscription interested in the message?booleanmatches(org.apache.activemq.command.ActiveMQDestination destination) Is the subscription interested in messages in the destination?List<org.apache.activemq.broker.region.MessageReference>remove(ConnectionContext context, Destination destination) The subscription will be no longer be receiving messages from the destination.voidremoveDestination(Destination destination) Remove a destinationvoidvoidsetCursorMemoryHighWaterMark(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(org.apache.activemq.broker.region.MessageReference node) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 Details
-
broker
-
context
-
info
protected org.apache.activemq.command.ConsumerInfo info -
destinationFilter
protected final org.apache.activemq.filter.DestinationFilter destinationFilter -
destinations
-
prefetchExtension
-
-
Constructor Details
-
AbstractSubscription
public AbstractSubscription(Broker broker, ConnectionContext context, org.apache.activemq.command.ConsumerInfo info) throws jakarta.jms.InvalidSelectorException - Throws:
jakarta.jms.InvalidSelectorException
-
-
Method Details
-
acknowledge
public void acknowledge(ConnectionContext context, org.apache.activemq.command.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(org.apache.activemq.broker.region.MessageReference node, org.apache.activemq.filter.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(org.apache.activemq.command.ActiveMQDestination destination) Description copied from interface:SubscriptionIs the subscription interested in messages in the destination?- Specified by:
matchesin interfaceSubscription- Returns:
- true if matching
-
add
Description copied from interface:SubscriptionThe subscription will be receiving messages from the destination.- Specified by:
addin interfaceSubscription- Throws:
Exception
-
remove
public List<org.apache.activemq.broker.region.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 org.apache.activemq.command.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
- Specified by:
getContextin interfaceSubscription
-
getInfo
public org.apache.activemq.command.ConsumerInfo getInfo() -
getSelectorExpression
public org.apache.activemq.filter.BooleanExpression getSelectorExpression() -
getSelector
- Specified by:
getSelectorin interfaceSubscription- Returns:
- the JMS selector on the current subscription
-
setSelector
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:
jakarta.jms.InvalidSelectorException
-
getObjectName
- Specified by:
getObjectNamein interfaceSubscription- Returns:
- the JMX object name that this subscription was registered as if applicable
-
setObjectName
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:
-
isSlowConsumer
public boolean isSlowConsumer()- Specified by:
isSlowConsumerin interfaceSubscription
-
setSlowConsumer
public void setSlowConsumer(boolean val) -
addRecoveredMessage
public boolean addRecoveredMessage(ConnectionContext context, org.apache.activemq.broker.region.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 org.apache.activemq.command.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
Add a destination- Parameters:
destination-
-
removeDestination
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
- Specified by:
unmatchedin interfaceSubscription- Throws:
IOException
-
doAddRecoveredMessage
protected void doAddRecoveredMessage(org.apache.activemq.broker.region.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
- Specified by:
getSubscriptionStatisticsin interfaceSubscription
-
wakeupDestinationsForDispatch
public void wakeupDestinationsForDispatch() -
getPrefetchExtension
-
contractPrefetchExtension
protected void contractPrefetchExtension(int amount) -
expandPrefetchExtension
protected void expandPrefetchExtension(int amount) -
decrementPrefetchExtension
protected void decrementPrefetchExtension(int amount) -
getDestinations
-