Class TopicSubscription
java.lang.Object
org.apache.activemq.broker.region.AbstractSubscription
org.apache.activemq.broker.region.TopicSubscription
- All Implemented Interfaces:
Subscription,SubscriptionRecovery
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected org.apache.activemq.ActiveMQMessageAuditprotected final AtomicIntegerprotected booleanprotected final List<org.apache.activemq.broker.region.TopicSubscription.DispatchedNode>protected final Objectprotected booleanprotected PendingMessageCursorprotected intprotected intprotected final SystemUsageFields inherited from class org.apache.activemq.broker.region.AbstractSubscription
broker, context, destinationFilter, destinations, info, prefetchExtension -
Constructor Summary
ConstructorsConstructorDescriptionTopicSubscription(Broker broker, ConnectionContext context, org.apache.activemq.command.ConsumerInfo info, SystemUsage usageManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidacknowledge(ConnectionContext context, org.apache.activemq.command.MessageAck ack) Used when client acknowledge receipt of dispatched message.voidadd(org.apache.activemq.broker.region.MessageReference node) Used to add messages that match the subscription.intvoiddestroy()Called when the subscription is destroyed.intlonglongintlongintintintintintlongintintvoidinit()booleanbooleanisFull()booleanbooleanbooleanintmatched()voidprocessMessageDispatchNotification(org.apache.activemq.command.MessageDispatchNotification mdn) Used by a Slave Broker to update dispatch infomationorg.apache.activemq.command.ResponsepullMessage(ConnectionContext context, org.apache.activemq.command.MessagePull pull) Allows a consumer to pull a message on demandList<org.apache.activemq.broker.region.MessageReference>remove(ConnectionContext context, Destination destination) The subscription will be no longer be receiving messages from the destination.protected voidDiscard any expired messages from the matched list.voidsetEnableAudit(boolean enableAudit) voidsetMatched(PendingMessageCursor matched) voidsetMaxAuditDepth(int maxAuditDepth) voidsetMaximumPendingMessages(int maximumPendingMessages) Sets the maximum number of pending messages that can be matched against this consumer before old messages are discarded.voidsetMaxProducersToAudit(int maxProducersToAudit) voidsetMemoryUsageHighWaterMark(int memoryUsageHighWaterMark) voidsetMessageEvictionStrategy(MessageEvictionStrategy messageEvictionStrategy) Sets the eviction strategy used to decide which message to evict when the slow consumer needs to discard messagesvoidsetPrefetchSize(int newSize) voidsetUseTopicSubscriptionInflightStats(boolean useTopicSubscriptionInflightStats) toString()voidupdateConsumerPrefetch(int newPrefetch) inform the MessageConsumer on the client to change it's prefetchMethods inherited from class org.apache.activemq.broker.region.AbstractSubscription
add, addDestination, addRecoveredMessage, contractPrefetchExtension, decrementPrefetchExtension, doAddRecoveredMessage, expandPrefetchExtension, gc, getActiveMQDestination, getConsumedCount, getConsumerInfo, getContext, getCursorMemoryHighWaterMark, getDestinations, getInFlightMessageSize, getInFlightUsage, getInfo, getObjectName, getPrefetchExtension, getSelector, getSelectorExpression, getSubscriptionStatistics, getTimeOfLastMessageAck, incrementConsumedCount, isBrowser, isRecoveryRequired, isSlowConsumer, isUsePrefetchExtension, isWildcard, matches, matches, removeDestination, resetConsumedCount, setCursorMemoryHighWaterMark, setObjectName, setSelector, setSlowConsumer, setTimeOfLastMessageAck, setUsePrefetchExtension, unmatched, wakeupDestinationsForDispatch
-
Field Details
-
matched
-
usageManager
-
maxProducersToAudit
protected int maxProducersToAudit -
maxAuditDepth
protected int maxAuditDepth -
enableAudit
protected boolean enableAudit -
audit
protected org.apache.activemq.ActiveMQMessageAudit audit -
active
protected boolean active -
discarding
protected boolean discarding -
dispatchLock
-
dispatched
-
currentDispatchedCount
-
-
Constructor Details
-
TopicSubscription
public TopicSubscription(Broker broker, ConnectionContext context, org.apache.activemq.command.ConsumerInfo info, SystemUsage usageManager) throws Exception - Throws:
Exception
-
-
Method Details
-
init
- Throws:
Exception
-
add
Description copied from interface:SubscriptionUsed to add messages that match the subscription.- Throws:
ExceptionInterruptedExceptionIOException
-
removeExpiredMessages
Discard any expired messages from the matched list. Called from a synchronized block.- Throws:
IOException
-
processMessageDispatchNotification
public void processMessageDispatchNotification(org.apache.activemq.command.MessageDispatchNotification mdn) Description copied from interface:SubscriptionUsed by a Slave Broker to update dispatch infomation -
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- Overrides:
acknowledgein classAbstractSubscription- Throws:
IOExceptionException
-
pullMessage
public org.apache.activemq.command.Response pullMessage(ConnectionContext context, org.apache.activemq.command.MessagePull pull) throws Exception Description copied from interface:SubscriptionAllows a consumer to pull a message on demand- 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- Overrides:
removein classAbstractSubscription- Returns:
- a list of un-acked messages that were added to the subscription.
- Throws:
Exception
-
countBeforeFull
public int countBeforeFull()- Specified by:
countBeforeFullin interfaceSubscription- Overrides:
countBeforeFullin classAbstractSubscription- Returns:
- the number of messages this subscription can accept before its full
-
getPendingQueueSize
public int getPendingQueueSize()- Returns:
- number of messages pending delivery
-
getPendingMessageSize
public long getPendingMessageSize()- Returns:
- size of the 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
-
setMessageEvictionStrategy
Sets the eviction strategy used to decide which message to evict when the slow consumer needs to discard messages -
getMaxProducersToAudit
public int getMaxProducersToAudit() -
setMaxProducersToAudit
public void setMaxProducersToAudit(int maxProducersToAudit) -
getMaxAuditDepth
public int getMaxAuditDepth() -
setMaxAuditDepth
public void setMaxAuditDepth(int maxAuditDepth) -
isEnableAudit
public boolean isEnableAudit() -
setEnableAudit
public void setEnableAudit(boolean enableAudit) -
isFull
public boolean isFull()- Returns:
- true if there is no space to dispatch messages
-
getInFlightSize
public int getInFlightSize()- Returns:
- the number of messages awaiting acknowledgement
-
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
-
setMemoryUsageHighWaterMark
public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark) - Parameters:
memoryUsageHighWaterMark- the memoryUsageHighWaterMark to set
-
getMemoryUsageHighWaterMark
public int getMemoryUsageHighWaterMark()- Returns:
- the memoryUsageHighWaterMark
-
getUsageManager
- Returns:
- the usageManager
-
getMatched
- Returns:
- the matched
-
setMatched
- Parameters:
matched- the matched to set
-
updateConsumerPrefetch
public void updateConsumerPrefetch(int newPrefetch) inform the MessageConsumer on the client to change it's prefetch- Parameters:
newPrefetch-
-
toString
-
destroy
public void destroy()Description copied from interface:SubscriptionCalled when the subscription is destroyed. -
getPrefetchSize
public int getPrefetchSize()- Specified by:
getPrefetchSizein interfaceSubscription- Overrides:
getPrefetchSizein classAbstractSubscription- Returns:
- the prefetch size that is configured for the subscription
-
setPrefetchSize
public void setPrefetchSize(int newSize) - Overrides:
setPrefetchSizein classAbstractSubscription
-
isUseTopicSubscriptionInflightStats
public boolean isUseTopicSubscriptionInflightStats() -
setUseTopicSubscriptionInflightStats
public void setUseTopicSubscriptionInflightStats(boolean useTopicSubscriptionInflightStats)
-