Class PrefetchSubscription
java.lang.Object
org.apache.activemq.broker.region.AbstractSubscription
org.apache.activemq.broker.region.PrefetchSubscription
- All Implemented Interfaces:
Subscription,SubscriptionRecovery
- Direct Known Subclasses:
DurableTopicSubscription,QueueSubscription
A subscription that honors the pre-fetch option of the ConsumerInfo.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<org.apache.activemq.broker.region.MessageReference>protected final Objectprotected PendingMessageCursorprotected final Objectprotected final org.apache.activemq.thread.Schedulerprotected final SystemUsageFields inherited from class org.apache.activemq.broker.region.AbstractSubscription
broker, context, destinationFilter, destinations, info, prefetchExtension -
Constructor Summary
ConstructorsConstructorDescriptionPrefetchSubscription(Broker broker, SystemUsage usageManager, ConnectionContext context, org.apache.activemq.command.ConsumerInfo info) PrefetchSubscription(Broker broker, SystemUsage usageManager, ConnectionContext context, org.apache.activemq.command.ConsumerInfo info, PendingMessageCursor cursor) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidacknowledge(ConnectionContext context, org.apache.activemq.command.MessageAck ack) Used when client acknowledge receipt of dispatched message.protected abstract voidacknowledge(ConnectionContext context, org.apache.activemq.command.MessageAck ack, org.apache.activemq.broker.region.MessageReference node) Used during acknowledgment to remove the message.voidadd(ConnectionContext context, Destination destination) The subscription will be receiving messages from the destination.voidadd(org.apache.activemq.broker.region.MessageReference node) Used to add messages that match the subscription.protected voidassertAckMatchesDispatched(org.apache.activemq.command.MessageAck ack) Checks an ack versus the contents of the dispatched list.protected abstract booleancanDispatch(org.apache.activemq.broker.region.MessageReference node) Use when a matched message is about to be dispatched to the client.intprotected org.apache.activemq.command.MessageDispatchcreateMessageDispatch(org.apache.activemq.broker.region.MessageReference node, org.apache.activemq.command.Message message) protected booleandispatch(org.apache.activemq.broker.region.MessageReference node) voidlonglongintlongintintintlongintprotected abstract booleanisDropped(org.apache.activemq.broker.region.MessageReference node) booleanisFull()Used to determine if the broker can dispatch to the consumer.booleanbooleanbooleanInforms the Broker if the subscription needs to intervention to recover it's state e.g.protected voidonDispatch(org.apache.activemq.broker.region.MessageReference node, org.apache.activemq.command.Message message) 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 message to be pulled on demand by a clientList<org.apache.activemq.broker.region.MessageReference>remove(ConnectionContext context, Destination destination) The subscription will be no longer be receiving messages from the destination.List<org.apache.activemq.broker.region.MessageReference>remove(ConnectionContext context, Destination destination, List<org.apache.activemq.broker.region.MessageReference> dispatched) protected voidsendToDLQ(ConnectionContext context, org.apache.activemq.broker.region.MessageReference node, Throwable poisonCause) voidsetMaxAuditDepth(int maxAuditDepth) voidsetMaxProducersToAudit(int maxProducersToAudit) voidsetPending(PendingMessageCursor pending) protected voidsetPendingBatchSize(PendingMessageCursor pending, int numberToDispatch) voidsetPrefetchSize(int prefetchSize) protected booleantrackedInPendingTransaction(org.apache.activemq.broker.region.MessageReference node) voidupdateConsumerPrefetch(int newPrefetch) inform the MessageConsumer on the client to change it's prefetchMethods inherited from class org.apache.activemq.broker.region.AbstractSubscription
addDestination, addRecoveredMessage, contractPrefetchExtension, decrementPrefetchExtension, doAddRecoveredMessage, expandPrefetchExtension, gc, getActiveMQDestination, getConsumedCount, getConsumerInfo, getContext, getCursorMemoryHighWaterMark, getDestinations, getInFlightMessageSize, getInFlightUsage, getInfo, getObjectName, getPrefetchExtension, getPrefetchSize, getSelector, getSelectorExpression, getSubscriptionStatistics, getTimeOfLastMessageAck, incrementConsumedCount, isBrowser, isSlowConsumer, isUsePrefetchExtension, isWildcard, matches, matches, removeDestination, resetConsumedCount, setCursorMemoryHighWaterMark, setObjectName, setSelector, setSlowConsumer, setTimeOfLastMessageAck, setUsePrefetchExtension, unmatched, wakeupDestinationsForDispatchMethods 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
destroy
-
Field Details
-
scheduler
protected final org.apache.activemq.thread.Scheduler scheduler -
pending
-
dispatched
-
usageManager
-
pendingLock
-
dispatchLock
-
-
Constructor Details
-
PrefetchSubscription
public PrefetchSubscription(Broker broker, SystemUsage usageManager, ConnectionContext context, org.apache.activemq.command.ConsumerInfo info, PendingMessageCursor cursor) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
PrefetchSubscription
public PrefetchSubscription(Broker broker, SystemUsage usageManager, ConnectionContext context, org.apache.activemq.command.ConsumerInfo info) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
-
Method Details
-
pullMessage
public org.apache.activemq.command.Response pullMessage(ConnectionContext context, org.apache.activemq.command.MessagePull pull) throws Exception Allows a message to be pulled on demand by a client- Throws:
Exception
-
add
Description copied from interface:SubscriptionUsed to add messages that match the subscription.- Throws:
ExceptionInterruptedExceptionIOException
-
processMessageDispatchNotification
public void processMessageDispatchNotification(org.apache.activemq.command.MessageDispatchNotification mdn) throws Exception Description copied from interface:SubscriptionUsed by a Slave Broker to update dispatch infomation- Throws:
Exception
-
acknowledge
public final 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
-
assertAckMatchesDispatched
protected void assertAckMatchesDispatched(org.apache.activemq.command.MessageAck ack) throws jakarta.jms.JMSException Checks an ack versus the contents of the dispatched list. called with dispatchLock held- Parameters:
ack-- Throws:
jakarta.jms.JMSException- if it does not match
-
sendToDLQ
protected void sendToDLQ(ConnectionContext context, org.apache.activemq.broker.region.MessageReference node, Throwable poisonCause) throws IOException, Exception - Parameters:
context-node-poisonCause-- Throws:
IOExceptionException
-
getInFlightSize
public int getInFlightSize()- Returns:
- the number of messages awaiting acknowledgement
-
isFull
public boolean isFull()Used to determine if the broker can dispatch to the consumer.- Returns:
- true if the subscription is full
-
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
-
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
-
getDequeueCounter
public long getDequeueCounter()- Returns:
- number of messages queued by the client
-
getDispatchedCounter
public long getDispatchedCounter()- Returns:
- number of messages dispatched to the client
-
getEnqueueCounter
public long getEnqueueCounter()- Returns:
- number of messages that matched the subscription
-
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- Overrides:
isRecoveryRequiredin classAbstractSubscription- Returns:
- true if recovery required
- See Also:
-
getPending
-
setPending
-
add
Description copied from interface:SubscriptionThe subscription will be receiving messages from the destination.- Specified by:
addin interfaceSubscription- Overrides:
addin classAbstractSubscription- 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
-
remove
public List<org.apache.activemq.broker.region.MessageReference> remove(ConnectionContext context, Destination destination, List<org.apache.activemq.broker.region.MessageReference> dispatched) throws Exception - Throws:
Exception
-
dispatchPending
- Throws:
IOException
-
trackedInPendingTransaction
protected boolean trackedInPendingTransaction(org.apache.activemq.broker.region.MessageReference node) -
setPendingBatchSize
-
dispatch
protected boolean dispatch(org.apache.activemq.broker.region.MessageReference node) throws IOException - Throws:
IOException
-
onDispatch
protected void onDispatch(org.apache.activemq.broker.region.MessageReference node, org.apache.activemq.command.Message message) -
updateConsumerPrefetch
public void updateConsumerPrefetch(int newPrefetch) inform the MessageConsumer on the client to change it's prefetch- Parameters:
newPrefetch-
-
createMessageDispatch
protected org.apache.activemq.command.MessageDispatch createMessageDispatch(org.apache.activemq.broker.region.MessageReference node, org.apache.activemq.command.Message message) - Parameters:
node-message-- Returns:
- MessageDispatch
-
canDispatch
protected abstract boolean canDispatch(org.apache.activemq.broker.region.MessageReference node) throws IOException Use when a matched message is about to be dispatched to the client.- Parameters:
node-- Returns:
- false if the message should not be dispatched to the client (another sub may have already dispatched it for example).
- Throws:
IOException
-
isDropped
protected abstract boolean isDropped(org.apache.activemq.broker.region.MessageReference node) -
acknowledge
protected abstract void acknowledge(ConnectionContext context, org.apache.activemq.command.MessageAck ack, org.apache.activemq.broker.region.MessageReference node) throws IOException Used during acknowledgment to remove the message.- Throws:
IOException
-
getMaxProducersToAudit
public int getMaxProducersToAudit() -
setMaxProducersToAudit
public void setMaxProducersToAudit(int maxProducersToAudit) -
getMaxAuditDepth
public int getMaxAuditDepth() -
setMaxAuditDepth
public void setMaxAuditDepth(int maxAuditDepth) -
setPrefetchSize
public void setPrefetchSize(int prefetchSize) - Overrides:
setPrefetchSizein classAbstractSubscription
-