public class MessageGroupQueue
extends java.util.AbstractQueue<org.springframework.messaging.Message<?>>
implements java.util.concurrent.BlockingQueue<org.springframework.messaging.Message<?>>
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.Constructor and Description |
---|
MessageGroupQueue(BasicMessageGroupStore messageGroupStore,
java.lang.Object groupId) |
MessageGroupQueue(BasicMessageGroupStore messageGroupStore,
java.lang.Object groupId,
int capacity) |
MessageGroupQueue(BasicMessageGroupStore messageGroupStore,
java.lang.Object groupId,
int capacity,
java.util.concurrent.locks.Lock storeLock) |
MessageGroupQueue(BasicMessageGroupStore messageGroupStore,
java.lang.Object groupId,
java.util.concurrent.locks.Lock storeLock) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
doOffer(org.springframework.messaging.Message<?> message)
It is assumed that the 'storeLock' is being held by the caller, otherwise
IllegalMonitorStateException may be thrown.
|
protected org.springframework.messaging.Message<?> |
doPoll()
It is assumed that the 'storeLock' is being held by the caller, otherwise
IllegalMonitorStateException may be thrown.
|
int |
drainTo(java.util.Collection<? super org.springframework.messaging.Message<?>> c) |
int |
drainTo(java.util.Collection<? super org.springframework.messaging.Message<?>> collection,
int maxElements) |
protected BasicMessageGroupStore |
getMessageGroupStore()
Get the store.
|
protected java.util.Collection<org.springframework.messaging.Message<?>> |
getMessages() |
protected java.util.concurrent.locks.Condition |
getMessageStoreNotEmpty()
Get the not empty condition.
|
protected java.util.concurrent.locks.Condition |
getMessageStoreNotFull()
Get the not full condition.
|
protected java.util.concurrent.locks.Lock |
getStoreLock()
Get the store lock.
|
java.util.Iterator<org.springframework.messaging.Message<?>> |
iterator() |
boolean |
offer(org.springframework.messaging.Message<?> message) |
boolean |
offer(org.springframework.messaging.Message<?> message,
long timeout,
java.util.concurrent.TimeUnit unit) |
org.springframework.messaging.Message<?> |
peek() |
org.springframework.messaging.Message<?> |
poll() |
org.springframework.messaging.Message<?> |
poll(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
put(org.springframework.messaging.Message<?> message) |
int |
remainingCapacity() |
void |
setPriority(boolean priority)
If true, ensures that the message store supports priority.
|
int |
size() |
org.springframework.messaging.Message<?> |
take() |
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public MessageGroupQueue(BasicMessageGroupStore messageGroupStore, java.lang.Object groupId)
public MessageGroupQueue(BasicMessageGroupStore messageGroupStore, java.lang.Object groupId, int capacity)
public MessageGroupQueue(BasicMessageGroupStore messageGroupStore, java.lang.Object groupId, java.util.concurrent.locks.Lock storeLock)
public MessageGroupQueue(BasicMessageGroupStore messageGroupStore, java.lang.Object groupId, int capacity, java.util.concurrent.locks.Lock storeLock)
public void setPriority(boolean priority)
priority
- true if priority is expected to be used.public java.util.Iterator<org.springframework.messaging.Message<?>> iterator()
iterator
in interface java.lang.Iterable<org.springframework.messaging.Message<?>>
iterator
in interface java.util.Collection<org.springframework.messaging.Message<?>>
iterator
in class java.util.AbstractCollection<org.springframework.messaging.Message<?>>
protected BasicMessageGroupStore getMessageGroupStore()
protected java.util.concurrent.locks.Lock getStoreLock()
protected java.util.concurrent.locks.Condition getMessageStoreNotFull()
protected java.util.concurrent.locks.Condition getMessageStoreNotEmpty()
public int size()
size
in interface java.util.Collection<org.springframework.messaging.Message<?>>
size
in class java.util.AbstractCollection<org.springframework.messaging.Message<?>>
public org.springframework.messaging.Message<?> peek()
peek
in interface java.util.Queue<org.springframework.messaging.Message<?>>
public org.springframework.messaging.Message<?> poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
poll
in interface java.util.concurrent.BlockingQueue<org.springframework.messaging.Message<?>>
java.lang.InterruptedException
public org.springframework.messaging.Message<?> poll()
poll
in interface java.util.Queue<org.springframework.messaging.Message<?>>
public int drainTo(java.util.Collection<? super org.springframework.messaging.Message<?>> c)
drainTo
in interface java.util.concurrent.BlockingQueue<org.springframework.messaging.Message<?>>
public int drainTo(java.util.Collection<? super org.springframework.messaging.Message<?>> collection, int maxElements)
drainTo
in interface java.util.concurrent.BlockingQueue<org.springframework.messaging.Message<?>>
public boolean offer(org.springframework.messaging.Message<?> message)
offer
in interface java.util.concurrent.BlockingQueue<org.springframework.messaging.Message<?>>
offer
in interface java.util.Queue<org.springframework.messaging.Message<?>>
public boolean offer(org.springframework.messaging.Message<?> message, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
offer
in interface java.util.concurrent.BlockingQueue<org.springframework.messaging.Message<?>>
java.lang.InterruptedException
public void put(org.springframework.messaging.Message<?> message) throws java.lang.InterruptedException
put
in interface java.util.concurrent.BlockingQueue<org.springframework.messaging.Message<?>>
java.lang.InterruptedException
public int remainingCapacity()
remainingCapacity
in interface java.util.concurrent.BlockingQueue<org.springframework.messaging.Message<?>>
public org.springframework.messaging.Message<?> take() throws java.lang.InterruptedException
take
in interface java.util.concurrent.BlockingQueue<org.springframework.messaging.Message<?>>
java.lang.InterruptedException
protected java.util.Collection<org.springframework.messaging.Message<?>> getMessages()
protected org.springframework.messaging.Message<?> doPoll()
protected boolean doOffer(org.springframework.messaging.Message<?> message)
message
- the message to offer.