Class AbstractPendingMessageCursor
- java.lang.Object
-
- org.apache.activemq.broker.region.cursors.AbstractPendingMessageCursor
-
- All Implemented Interfaces:
PendingMessageCursor
,Service
- Direct Known Subclasses:
AbstractStoreCursor
,FilePendingMessageCursor
,StoreDurableSubscriberCursor
,StoreQueueCursor
,VMPendingMessageCursor
public abstract class AbstractPendingMessageCursor extends Object implements PendingMessageCursor
Abstract method holder for pending message (messages awaiting disptach to a consumer) cursor
-
-
Field Summary
Fields Modifier and Type Field Description protected ActiveMQMessageAudit
audit
protected boolean
cacheEnabled
protected boolean
enableAudit
protected MessageReference
last
protected int
maxAuditDepth
protected int
maxBatchSize
protected int
maxProducersToAudit
protected int
memoryUsageHighWaterMark
protected boolean
prioritizedMessages
protected boolean
started
protected SystemUsage
systemUsage
protected boolean
useCache
-
Fields inherited from interface org.apache.activemq.broker.region.cursors.PendingMessageCursor
INFINITE_WAIT
-
-
Constructor Summary
Constructors Constructor Description AbstractPendingMessageCursor(boolean prioritizedMessages)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(ConnectionContext context, Destination destination)
Add a destinationvoid
addMessageFirst(MessageReference node)
add message to await dispatchboolean
addMessageLast(MessageReference node)
add message to await dispatchvoid
addRecoveredMessage(MessageReference node)
Add a message recovered from a retroactive policyvoid
clear()
clear all pending messagesvoid
destroy()
destroy the cursorprotected void
fillBatch()
void
gc()
free up any internal buffersint
getMaxAuditDepth()
int
getMaxBatchSize()
int
getMaxProducersToAudit()
int
getMemoryUsageHighWaterMark()
ActiveMQMessageAudit
getMessageAudit()
SystemUsage
getSystemUsage()
boolean
hasMessagesBufferedToDeliver()
boolean
hasNext()
boolean
hasSpace()
boolean
isCacheEnabled()
boolean
isDuplicate(MessageId messageId)
boolean
isEmpty()
boolean
isEmpty(Destination destination)
check if a Destination is Empty for this cursorboolean
isEnableAudit()
boolean
isFull()
static boolean
isPrioritizedMessageSubscriber(Broker broker, Subscription sub)
boolean
isRecoveryRequired()
Informs the Broker if the subscription needs to intervention to recover it's state e.g.boolean
isStarted()
boolean
isTransient()
boolean
isUseCache()
MessageReference
next()
LinkedList<MessageReference>
pageInList(int maxItems)
Page in a restricted number of messagesvoid
rebase()
boolean
recordUniqueId(MessageId messageId)
records a message id and checks if it is a duplicatevoid
release()
hint to the cursor to release any locks it might have grabbed after a resetvoid
remove()
remove the message at the cursor positionList<MessageReference>
remove(ConnectionContext context, Destination destination)
remove a destinationvoid
remove(MessageReference node)
remove a nodevoid
reset()
reset the cursorvoid
resetForGC()
Give the cursor a hint that we are about to remove messages from memory onlyvoid
rollback(MessageId id)
remove from auditing the message idvoid
setCacheEnabled(boolean val)
void
setEnableAudit(boolean enableAudit)
void
setMaxAuditDepth(int maxAuditDepth)
Set the maximum depth of message ids to trackvoid
setMaxBatchSize(int maxBatchSize)
Set the max batch sizevoid
setMaxProducersToAudit(int maxProducersToAudit)
set the maximum number of producers to track at one timevoid
setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark)
void
setMessageAudit(ActiveMQMessageAudit audit)
set the auditvoid
setSystemUsage(SystemUsage usageManager)
Set the UsageManagervoid
setUseCache(boolean useCache)
use a cache to improve performanceint
size()
void
start()
void
stop()
boolean
tryAddMessageLast(MessageReference node, long maxWaitTime)
add message to await dispatch - if it can-
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.cursors.PendingMessageCursor
messageSize
-
-
-
-
Field Detail
-
memoryUsageHighWaterMark
protected int memoryUsageHighWaterMark
-
maxBatchSize
protected int maxBatchSize
-
systemUsage
protected SystemUsage systemUsage
-
maxProducersToAudit
protected int maxProducersToAudit
-
maxAuditDepth
protected int maxAuditDepth
-
enableAudit
protected boolean enableAudit
-
audit
protected ActiveMQMessageAudit audit
-
useCache
protected boolean useCache
-
cacheEnabled
protected boolean cacheEnabled
-
started
protected boolean started
-
last
protected MessageReference last
-
prioritizedMessages
protected final boolean prioritizedMessages
-
-
Method Detail
-
start
public void start() throws Exception
-
add
public void add(ConnectionContext context, Destination destination) throws Exception
Description copied from interface:PendingMessageCursor
Add a destination- Specified by:
add
in interfacePendingMessageCursor
- Throws:
Exception
-
remove
public List<MessageReference> remove(ConnectionContext context, Destination destination) throws Exception
Description copied from interface:PendingMessageCursor
remove a destination- Specified by:
remove
in interfacePendingMessageCursor
- Throws:
Exception
-
isRecoveryRequired
public boolean isRecoveryRequired()
Description copied from interface:PendingMessageCursor
Informs the Broker if the subscription needs to intervention to recover it's state e.g. DurableTopicSubscriber may do- Specified by:
isRecoveryRequired
in interfacePendingMessageCursor
- Returns:
- true if recovery required
-
addMessageFirst
public void addMessageFirst(MessageReference node) throws Exception
Description copied from interface:PendingMessageCursor
add message to await dispatch- Specified by:
addMessageFirst
in interfacePendingMessageCursor
- Throws:
Exception
-
addMessageLast
public boolean addMessageLast(MessageReference node) throws Exception
Description copied from interface:PendingMessageCursor
add message to await dispatch- Specified by:
addMessageLast
in interfacePendingMessageCursor
- Returns:
- boolean true if successful, false if cursor traps a duplicate
- Throws:
IOException
Exception
-
tryAddMessageLast
public boolean tryAddMessageLast(MessageReference node, long maxWaitTime) throws Exception
Description copied from interface:PendingMessageCursor
add message to await dispatch - if it can- Specified by:
tryAddMessageLast
in interfacePendingMessageCursor
- Returns:
- true if successful
- Throws:
IOException
Exception
-
addRecoveredMessage
public void addRecoveredMessage(MessageReference node) throws Exception
Description copied from interface:PendingMessageCursor
Add a message recovered from a retroactive policy- Specified by:
addRecoveredMessage
in interfacePendingMessageCursor
- Throws:
Exception
-
clear
public void clear()
Description copied from interface:PendingMessageCursor
clear all pending messages- Specified by:
clear
in interfacePendingMessageCursor
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacePendingMessageCursor
- Returns:
- true if there pending messages to dispatch
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacePendingMessageCursor
- Returns:
- true if there are no pending messages
-
isEmpty
public boolean isEmpty(Destination destination)
Description copied from interface:PendingMessageCursor
check if a Destination is Empty for this cursor- Specified by:
isEmpty
in interfacePendingMessageCursor
- Returns:
- true id the Destination is empty
-
next
public MessageReference next()
- Specified by:
next
in interfacePendingMessageCursor
- Returns:
- the next pending message with its reference count increment
-
remove
public void remove()
Description copied from interface:PendingMessageCursor
remove the message at the cursor position- Specified by:
remove
in interfacePendingMessageCursor
-
reset
public void reset()
Description copied from interface:PendingMessageCursor
reset the cursor- Specified by:
reset
in interfacePendingMessageCursor
-
size
public int size()
- Specified by:
size
in interfacePendingMessageCursor
- Returns:
- the number of pending messages
-
getMaxBatchSize
public int getMaxBatchSize()
- Specified by:
getMaxBatchSize
in interfacePendingMessageCursor
- Returns:
- the maximum batch size
-
setMaxBatchSize
public void setMaxBatchSize(int maxBatchSize)
Description copied from interface:PendingMessageCursor
Set the max batch size- Specified by:
setMaxBatchSize
in interfacePendingMessageCursor
-
resetForGC
public void resetForGC()
Description copied from interface:PendingMessageCursor
Give the cursor a hint that we are about to remove messages from memory only- Specified by:
resetForGC
in interfacePendingMessageCursor
-
remove
public void remove(MessageReference node)
Description copied from interface:PendingMessageCursor
remove a node- Specified by:
remove
in interfacePendingMessageCursor
-
gc
public void gc()
Description copied from interface:PendingMessageCursor
free up any internal buffers- Specified by:
gc
in interfacePendingMessageCursor
-
setSystemUsage
public void setSystemUsage(SystemUsage usageManager)
Description copied from interface:PendingMessageCursor
Set the UsageManager- Specified by:
setSystemUsage
in interfacePendingMessageCursor
- See Also:
SystemUsage
-
hasSpace
public boolean hasSpace()
- Specified by:
hasSpace
in interfacePendingMessageCursor
- Returns:
- true if the cursor has space to page messages into
-
isFull
public boolean isFull()
- Specified by:
isFull
in interfacePendingMessageCursor
- Returns:
- true if the cursor is full
-
release
public void release()
Description copied from interface:PendingMessageCursor
hint to the cursor to release any locks it might have grabbed after a reset- Specified by:
release
in interfacePendingMessageCursor
-
hasMessagesBufferedToDeliver
public boolean hasMessagesBufferedToDeliver()
- Specified by:
hasMessagesBufferedToDeliver
in interfacePendingMessageCursor
- Returns:
- true if the cursor has buffered messages ready to deliver
-
getMemoryUsageHighWaterMark
public int getMemoryUsageHighWaterMark()
- Specified by:
getMemoryUsageHighWaterMark
in interfacePendingMessageCursor
- Returns:
- the memoryUsageHighWaterMark
-
setMemoryUsageHighWaterMark
public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark)
- Specified by:
setMemoryUsageHighWaterMark
in interfacePendingMessageCursor
- Parameters:
memoryUsageHighWaterMark
- the memoryUsageHighWaterMark to set
-
getSystemUsage
public SystemUsage getSystemUsage()
- Specified by:
getSystemUsage
in interfacePendingMessageCursor
- Returns:
- the usageManager
-
destroy
public void destroy() throws Exception
destroy the cursor- Specified by:
destroy
in interfacePendingMessageCursor
- Throws:
Exception
-
pageInList
public LinkedList<MessageReference> pageInList(int maxItems)
Page in a restricted number of messages- Specified by:
pageInList
in interfacePendingMessageCursor
- Parameters:
maxItems
- maximum number of messages to return- Returns:
- a list of paged in messages
-
getMaxProducersToAudit
public int getMaxProducersToAudit()
- Specified by:
getMaxProducersToAudit
in interfacePendingMessageCursor
- Returns:
- the maxProducersToAudit
-
setMaxProducersToAudit
public void setMaxProducersToAudit(int maxProducersToAudit)
Description copied from interface:PendingMessageCursor
set the maximum number of producers to track at one time- Specified by:
setMaxProducersToAudit
in interfacePendingMessageCursor
- Parameters:
maxProducersToAudit
- the maxProducersToAudit to set
-
getMaxAuditDepth
public int getMaxAuditDepth()
- Specified by:
getMaxAuditDepth
in interfacePendingMessageCursor
- Returns:
- the maxAuditDepth
-
setMaxAuditDepth
public void setMaxAuditDepth(int maxAuditDepth)
Description copied from interface:PendingMessageCursor
Set the maximum depth of message ids to track- Specified by:
setMaxAuditDepth
in interfacePendingMessageCursor
- Parameters:
maxAuditDepth
- the maxAuditDepth to set
-
isEnableAudit
public boolean isEnableAudit()
- Specified by:
isEnableAudit
in interfacePendingMessageCursor
- Returns:
- the enableAudit
-
setEnableAudit
public void setEnableAudit(boolean enableAudit)
- Specified by:
setEnableAudit
in interfacePendingMessageCursor
- Parameters:
enableAudit
- the enableAudit to set
-
isTransient
public boolean isTransient()
- Specified by:
isTransient
in interfacePendingMessageCursor
- Returns:
- true if the underlying state of this cursor disappears when the broker shuts down
-
setMessageAudit
public void setMessageAudit(ActiveMQMessageAudit audit)
set the audit- Specified by:
setMessageAudit
in interfacePendingMessageCursor
- Parameters:
audit
- new audit component
-
getMessageAudit
public ActiveMQMessageAudit getMessageAudit()
- Specified by:
getMessageAudit
in interfacePendingMessageCursor
- Returns:
- the audit
-
isUseCache
public boolean isUseCache()
- Specified by:
isUseCache
in interfacePendingMessageCursor
- Returns:
- true if a cache may be used
-
setUseCache
public void setUseCache(boolean useCache)
Description copied from interface:PendingMessageCursor
use a cache to improve performance- Specified by:
setUseCache
in interfacePendingMessageCursor
-
isDuplicate
public boolean isDuplicate(MessageId messageId)
-
recordUniqueId
public boolean recordUniqueId(MessageId messageId)
records a message id and checks if it is a duplicate- Parameters:
messageId
-- Returns:
- true if id is unique, false otherwise.
-
rollback
public void rollback(MessageId id)
Description copied from interface:PendingMessageCursor
remove from auditing the message id- Specified by:
rollback
in interfacePendingMessageCursor
-
isStarted
public boolean isStarted()
-
isPrioritizedMessageSubscriber
public static boolean isPrioritizedMessageSubscriber(Broker broker, Subscription sub)
-
isCacheEnabled
public boolean isCacheEnabled()
- Specified by:
isCacheEnabled
in interfacePendingMessageCursor
- Returns:
- true if cache is being used
-
setCacheEnabled
public void setCacheEnabled(boolean val)
-
rebase
public void rebase()
- Specified by:
rebase
in interfacePendingMessageCursor
-
-