Class MessageGroupQueue
- All Implemented Interfaces:
- Iterable<Message<?>>,- Collection<Message<?>>,- BlockingQueue<Message<?>>,- Queue<Message<?>>
public class MessageGroupQueue
extends AbstractQueue<Message<?>>
implements BlockingQueue<Message<?>>
A 
BlockingQueue that is backed by a MessageGroupStore. Can be used to ensure guaranteed delivery in
 the face of transaction rollback (assuming the store is transactional) and also to ensure messages are not lost if
 the process dies (assuming the store is durable). To use the queue across process re-starts, the same group id
 must be provided, so it needs to be unique but identifiable with a single logical instance of the queue.- Since:
- 2.0
- Author:
- Dave Syer, Oleg Zhurakousky, Gunnar Hillert, Gary Russell, Artem Bilan
- 
Constructor SummaryConstructorsConstructorDescriptionMessageGroupQueue(BasicMessageGroupStore messageGroupStore, Object groupId) MessageGroupQueue(BasicMessageGroupStore messageGroupStore, Object groupId, int capacity) MessageGroupQueue(BasicMessageGroupStore messageGroupStore, Object groupId, int capacity, Lock storeLock) MessageGroupQueue(BasicMessageGroupStore messageGroupStore, Object groupId, Lock storeLock) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleanIt is assumed that the 'storeLock' is being held by the caller, otherwise IllegalMonitorStateException may be thrown.protected Message<?> doPoll()It is assumed that the 'storeLock' is being held by the caller, otherwise IllegalMonitorStateException may be thrown.intdrainTo(Collection<? super Message<?>> c) intdrainTo(Collection<? super Message<?>> collection, int maxElements) protected BasicMessageGroupStoreGet the store.protected Collection<Message<?>> protected ConditionGet the not empty condition.protected ConditionGet the not full condition.protected LockGet the store lock.iterator()booleanbooleanMessage<?> peek()Message<?> poll()Message<?> voidintvoidsetPriority(boolean priority) If true, ensures that the message store supports priority.intsize()stream()Message<?> take()Methods inherited from class java.util.AbstractCollectioncontains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.BlockingQueueadd, contains, removeMethods inherited from interface java.util.CollectionaddAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, toArray, toArray, toArray
- 
Constructor Details- 
MessageGroupQueue
- 
MessageGroupQueue
- 
MessageGroupQueue
- 
MessageGroupQueuepublic MessageGroupQueue(BasicMessageGroupStore messageGroupStore, Object groupId, int capacity, Lock storeLock) 
 
- 
- 
Method Details- 
setPrioritypublic void setPriority(boolean priority) If true, ensures that the message store supports priority. If false WARNs if the message store uses priority to determine the message order when receiving.- Parameters:
- priority- true if priority is expected to be used.
 
- 
iterator
- 
getMessageGroupStoreGet the store.- Returns:
- the store.
- Since:
- 5.0.11
 
- 
getStoreLock
- 
getMessageStoreNotFullGet the not full condition.- Returns:
- the condition.
- Since:
- 5.0.11
 
- 
getMessageStoreNotEmptyGet the not empty condition.- Returns:
- the condition.
- Since:
- 5.0.11
 
- 
sizepublic int size()- Specified by:
- sizein interface- Collection<Message<?>>
- Specified by:
- sizein class- AbstractCollection<Message<?>>
 
- 
peek
- 
poll- Specified by:
- pollin interface- BlockingQueue<Message<?>>
- Throws:
- InterruptedException
 
- 
poll
- 
drainTo- Specified by:
- drainToin interface- BlockingQueue<Message<?>>
 
- 
drainTo- Specified by:
- drainToin interface- BlockingQueue<Message<?>>
 
- 
offer
- 
offer- Specified by:
- offerin interface- BlockingQueue<Message<?>>
- Throws:
- InterruptedException
 
- 
put- Specified by:
- putin interface- BlockingQueue<Message<?>>
- Throws:
- InterruptedException
 
- 
remainingCapacitypublic int remainingCapacity()- Specified by:
- remainingCapacityin interface- BlockingQueue<Message<?>>
 
- 
take- Specified by:
- takein interface- BlockingQueue<Message<?>>
- Throws:
- InterruptedException
 
- 
getMessages
- 
stream- Specified by:
- streamin interface- Collection<Message<?>>
 
- 
doPollIt is assumed that the 'storeLock' is being held by the caller, otherwise IllegalMonitorStateException may be thrown.- Returns:
- a message // TODO @Nullable
 
- 
doOfferIt is assumed that the 'storeLock' is being held by the caller, otherwise IllegalMonitorStateException may be thrown.- Parameters:
- message- the message to offer.
- Returns:
- true if offered.
 
 
-