public class MessageGroupQueue extends java.util.AbstractQueue<Message<?>> implements java.util.concurrent.BlockingQueue<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 |
---|---|
int |
drainTo(java.util.Collection<? super Message<?>> c) |
int |
drainTo(java.util.Collection<? super Message<?>> collection,
int maxElements) |
java.util.Iterator<Message<?>> |
iterator() |
boolean |
offer(Message<?> message) |
boolean |
offer(Message<?> message,
long timeout,
java.util.concurrent.TimeUnit unit) |
Message<?> |
peek() |
Message<?> |
poll() |
Message<?> |
poll(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
put(Message<?> message) |
int |
remainingCapacity() |
void |
setPriority(boolean priority)
If true, ensures that the message store supports priority.
|
int |
size() |
Message<?> |
take() |
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
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<Message<?>> iterator()
public int size()
public Message<?> poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
poll
in interface java.util.concurrent.BlockingQueue<Message<?>>
java.lang.InterruptedException
public int drainTo(java.util.Collection<? super Message<?>> c)
drainTo
in interface java.util.concurrent.BlockingQueue<Message<?>>
public int drainTo(java.util.Collection<? super Message<?>> collection, int maxElements)
drainTo
in interface java.util.concurrent.BlockingQueue<Message<?>>
public boolean offer(Message<?> message)
public boolean offer(Message<?> message, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
offer
in interface java.util.concurrent.BlockingQueue<Message<?>>
java.lang.InterruptedException
public void put(Message<?> message) throws java.lang.InterruptedException
put
in interface java.util.concurrent.BlockingQueue<Message<?>>
java.lang.InterruptedException
public int remainingCapacity()
remainingCapacity
in interface java.util.concurrent.BlockingQueue<Message<?>>