org.apache.activemq.broker.region.cursors
Class AbstractPendingMessageCursor

java.lang.Object
  extended by 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
protected  ActiveMQMessageAudit audit
           
protected  boolean enableAudit
           
protected  MessageReference last
           
protected  int maxAuditDepth
           
protected  int maxBatchSize
           
protected  int maxProducersToAudit
           
protected  int memoryUsageHighWaterMark
           
protected  boolean prioritizedMessages
           
protected  SystemUsage systemUsage
           
protected  boolean useCache
           
 
Constructor Summary
AbstractPendingMessageCursor(boolean prioritizedMessages)
           
 
Method Summary
 void add(ConnectionContext context, Destination destination)
          Add a destination
 void addMessageFirst(MessageReference node)
          add message to await dispatch
 void addMessageLast(MessageReference node)
          add message to await dispatch
 void addRecoveredMessage(MessageReference node)
          Add a message recovered from a retroactive policy
 void clear()
          clear all pending messages
 void destroy()
          destroy the cursor
protected  void fillBatch()
           
 void gc()
          free up any internal buffers
 int 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 cursor
 boolean 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.
protected  boolean isStarted()
           
 boolean isTransient()
           
 boolean isUseCache()
           
 MessageReference next()
           
 LinkedList<MessageReference> pageInList(int maxItems)
          Page in a restricted number of messages
 boolean recordUniqueId(MessageId messageId)
          records a message id and checks if it is a duplicate
 void release()
          hint to the cursor to release any locks it might have grabbed after a reset
 void remove()
          remove the message at the cursor position
 List<MessageReference> remove(ConnectionContext context, Destination destination)
          remove a destination
 void remove(MessageReference node)
          remove a node
 void reset()
          reset the cursor
 void resetForGC()
          Give the cursor a hint that we are about to remove messages from memory only
 void rollback(MessageId id)
          remove from auditing the message id
 void setCacheEnabled(boolean val)
           
 void setEnableAudit(boolean enableAudit)
           
 void setMaxAuditDepth(int maxAuditDepth)
          Set the maximum depth of message ids to track
 void setMaxBatchSize(int maxBatchSize)
          Set the max batch size
 void setMaxProducersToAudit(int maxProducersToAudit)
          set the maximum number of producers to track at one time
 void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark)
           
 void setMessageAudit(ActiveMQMessageAudit audit)
          set the audit
 void setSystemUsage(SystemUsage usageManager)
          Set the UsageManager
 void setUseCache(boolean useCache)
          use a cache to improve performance
 int 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
 

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

last

protected MessageReference last

prioritizedMessages

protected final boolean prioritizedMessages
Constructor Detail

AbstractPendingMessageCursor

public AbstractPendingMessageCursor(boolean prioritizedMessages)
Method Detail

start

public void start()
           throws Exception
Specified by:
start in interface Service
Throws:
Exception

stop

public void stop()
          throws Exception
Specified by:
stop in interface Service
Throws:
Exception

add

public void add(ConnectionContext context,
                Destination destination)
         throws Exception
Description copied from interface: PendingMessageCursor
Add a destination

Specified by:
add in interface PendingMessageCursor
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 interface PendingMessageCursor
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 interface PendingMessageCursor
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 interface PendingMessageCursor
Throws:
Exception

addMessageLast

public void addMessageLast(MessageReference node)
                    throws Exception
Description copied from interface: PendingMessageCursor
add message to await dispatch

Specified by:
addMessageLast in interface PendingMessageCursor
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 interface PendingMessageCursor
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 interface PendingMessageCursor
Throws:
Exception

clear

public void clear()
Description copied from interface: PendingMessageCursor
clear all pending messages

Specified by:
clear in interface PendingMessageCursor

hasNext

public boolean hasNext()
Specified by:
hasNext in interface PendingMessageCursor
Returns:
true if there pending messages to dispatch

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface PendingMessageCursor
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 interface PendingMessageCursor
Returns:
true id the Destination is empty

next

public MessageReference next()
Specified by:
next in interface PendingMessageCursor
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 interface PendingMessageCursor

reset

public void reset()
Description copied from interface: PendingMessageCursor
reset the cursor

Specified by:
reset in interface PendingMessageCursor

size

public int size()
Specified by:
size in interface PendingMessageCursor
Returns:
the number of pending messages

getMaxBatchSize

public int getMaxBatchSize()
Specified by:
getMaxBatchSize in interface PendingMessageCursor
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 interface PendingMessageCursor

fillBatch

protected void fillBatch()
                  throws Exception
Throws:
Exception

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 interface PendingMessageCursor

remove

public void remove(MessageReference node)
Description copied from interface: PendingMessageCursor
remove a node

Specified by:
remove in interface PendingMessageCursor

gc

public void gc()
Description copied from interface: PendingMessageCursor
free up any internal buffers

Specified by:
gc in interface PendingMessageCursor

setSystemUsage

public void setSystemUsage(SystemUsage usageManager)
Description copied from interface: PendingMessageCursor
Set the UsageManager

Specified by:
setSystemUsage in interface PendingMessageCursor
See Also:
SystemUsage

hasSpace

public boolean hasSpace()
Specified by:
hasSpace in interface PendingMessageCursor
Returns:
true if the cursor has space to page messages into

isFull

public boolean isFull()
Specified by:
isFull in interface PendingMessageCursor
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 interface PendingMessageCursor

hasMessagesBufferedToDeliver

public boolean hasMessagesBufferedToDeliver()
Specified by:
hasMessagesBufferedToDeliver in interface PendingMessageCursor
Returns:
true if the cursor has buffered messages ready to deliver

getMemoryUsageHighWaterMark

public int getMemoryUsageHighWaterMark()
Specified by:
getMemoryUsageHighWaterMark in interface PendingMessageCursor
Returns:
the memoryUsageHighWaterMark

setMemoryUsageHighWaterMark

public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark)
Specified by:
setMemoryUsageHighWaterMark in interface PendingMessageCursor
Parameters:
memoryUsageHighWaterMark - the memoryUsageHighWaterMark to set

getSystemUsage

public SystemUsage getSystemUsage()
Specified by:
getSystemUsage in interface PendingMessageCursor
Returns:
the usageManager

destroy

public void destroy()
             throws Exception
destroy the cursor

Specified by:
destroy in interface PendingMessageCursor
Throws:
Exception

pageInList

public LinkedList<MessageReference> pageInList(int maxItems)
Page in a restricted number of messages

Specified by:
pageInList in interface PendingMessageCursor
Parameters:
maxItems - maximum number of messages to return
Returns:
a list of paged in messages

getMaxProducersToAudit

public int getMaxProducersToAudit()
Specified by:
getMaxProducersToAudit in interface PendingMessageCursor
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 interface PendingMessageCursor
Parameters:
maxProducersToAudit - the maxProducersToAudit to set

getMaxAuditDepth

public int getMaxAuditDepth()
Specified by:
getMaxAuditDepth in interface PendingMessageCursor
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 interface PendingMessageCursor
Parameters:
maxAuditDepth - the maxAuditDepth to set

isEnableAudit

public boolean isEnableAudit()
Specified by:
isEnableAudit in interface PendingMessageCursor
Returns:
the enableAudit

setEnableAudit

public void setEnableAudit(boolean enableAudit)
Specified by:
setEnableAudit in interface PendingMessageCursor
Parameters:
enableAudit - the enableAudit to set

isTransient

public boolean isTransient()
Specified by:
isTransient in interface PendingMessageCursor
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 interface PendingMessageCursor
Parameters:
audit - new audit component

getMessageAudit

public ActiveMQMessageAudit getMessageAudit()
Specified by:
getMessageAudit in interface PendingMessageCursor
Returns:
the audit

isUseCache

public boolean isUseCache()
Specified by:
isUseCache in interface PendingMessageCursor
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 interface PendingMessageCursor

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 interface PendingMessageCursor

isStarted

protected boolean isStarted()

isPrioritizedMessageSubscriber

public static boolean isPrioritizedMessageSubscriber(Broker broker,
                                                     Subscription sub)

isCacheEnabled

public boolean isCacheEnabled()
Specified by:
isCacheEnabled in interface PendingMessageCursor
Returns:
true if cache is being used

setCacheEnabled

public void setCacheEnabled(boolean val)


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.