Class QueueDispatchPendingList
java.lang.Object
org.apache.activemq.broker.region.cursors.QueueDispatchPendingList
- All Implemented Interfaces:
Iterable<org.apache.activemq.broker.region.MessageReference>,PendingList
An abstraction that keeps the correct order of messages that need to be dispatched
to consumers, but also hides the fact that there might be redelivered messages that
should be dispatched ahead of any other paged in messages.
Direct usage of this class is recommended as you can control when redeliveries need
to be added vs regular pending messages (the next set of messages that can be dispatched)
Created by ceposta
<a href="http://christianposta.com/blog>http://christianposta.com/blog.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAll(PendingList pendingList) Adds all the elements of the given PendingList to this PendingList.voidaddForRedelivery(List<org.apache.activemq.broker.region.MessageReference> list, boolean noConsumers) addMessageFirst(org.apache.activemq.broker.region.MessageReference message) Messages added are added directly to the pagedInPendingDispatch set of messages.addMessageLast(org.apache.activemq.broker.region.MessageReference message) Messages added are added directly to the pagedInPendingDispatch set of messages.voidclear()Discards all Messages currently held in the PendingList.booleancontains(org.apache.activemq.broker.region.MessageReference message) Query the PendingList to determine if the given message is contained within.org.apache.activemq.broker.region.MessageReferenceget(org.apache.activemq.command.MessageId messageId) booleanbooleanisEmpty()Returns true if there are no Messages in the PendingList currently.Iterator<org.apache.activemq.broker.region.MessageReference>iterator()Returns an iterator over the pending Messages.longremove(org.apache.activemq.broker.region.MessageReference message) Removes the given MessageReference from the PendingList if it is contained within.voidsetPrioritizedMessages(boolean prioritizedMessages) intsize()Returns the number of MessageReferences that are awaiting dispatch.Collection<org.apache.activemq.broker.region.MessageReference>values()Returns a new Collection that contains all the MessageReferences currently held in this PendingList.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
QueueDispatchPendingList
public QueueDispatchPendingList()
-
-
Method Details
-
isEmpty
public boolean isEmpty()Description copied from interface:PendingListReturns true if there are no Messages in the PendingList currently.- Specified by:
isEmptyin interfacePendingList- Returns:
- true if the PendingList is currently empty.
-
clear
public void clear()Description copied from interface:PendingListDiscards all Messages currently held in the PendingList.- Specified by:
clearin interfacePendingList
-
addMessageFirst
Messages added are added directly to the pagedInPendingDispatch set of messages. If you're trying to add a message that is marked redelivered add it using addMessageForRedelivery() method- Specified by:
addMessageFirstin interfacePendingList- Parameters:
message- The MessageReference that is to be added to this list.- Returns:
- the pending node.
-
addMessageLast
Messages added are added directly to the pagedInPendingDispatch set of messages. If you're trying to add a message that is marked redelivered add it using addMessageForRedelivery() method- Specified by:
addMessageLastin interfacePendingList- Parameters:
message- The MessageReference that is to be added to this list.- Returns:
- the pending node.
-
remove
Description copied from interface:PendingListRemoves the given MessageReference from the PendingList if it is contained within.- Specified by:
removein interfacePendingList- Parameters:
message- The MessageReference that is to be removed to this list.- Returns:
- the PendingNode that contains the removed message or null if the message was not present in this list.
-
size
public int size()Description copied from interface:PendingListReturns the number of MessageReferences that are awaiting dispatch.- Specified by:
sizein interfacePendingList- Returns:
- current count of the pending messages.
-
messageSize
public long messageSize()- Specified by:
messageSizein interfacePendingList
-
iterator
Description copied from interface:PendingListReturns an iterator over the pending Messages. The subclass controls how the returned iterator actually traverses the list of pending messages allowing for the order to vary based on factors like Message priority or some other mechanism.- Specified by:
iteratorin interfaceIterable<org.apache.activemq.broker.region.MessageReference>- Specified by:
iteratorin interfacePendingList- Returns:
- an Iterator that returns MessageReferences contained in this list.
-
contains
public boolean contains(org.apache.activemq.broker.region.MessageReference message) Description copied from interface:PendingListQuery the PendingList to determine if the given message is contained within.- Specified by:
containsin interfacePendingList- Parameters:
message- The Message that is the target of this query.- Returns:
- true if the MessageReference is contained in this list.
-
values
Description copied from interface:PendingListReturns a new Collection that contains all the MessageReferences currently held in this PendingList. The elements of the list are ordered using the same rules as the subclass uses for iteration.- Specified by:
valuesin interfacePendingList- Returns:
- a new Collection containing this lists MessageReferences.
-
addAll
Description copied from interface:PendingListAdds all the elements of the given PendingList to this PendingList.- Specified by:
addAllin interfacePendingList- Parameters:
pendingList- The PendingList that is to be added to this collection.
-
get
public org.apache.activemq.broker.region.MessageReference get(org.apache.activemq.command.MessageId messageId) - Specified by:
getin interfacePendingList
-
setPrioritizedMessages
public void setPrioritizedMessages(boolean prioritizedMessages) -
hasRedeliveries
public boolean hasRedeliveries() -
addForRedelivery
public void addForRedelivery(List<org.apache.activemq.broker.region.MessageReference> list, boolean noConsumers)
-