org.springframework.integration.store
Class MessageGroupQueue

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<Message<?>>
          extended by org.springframework.integration.store.MessageGroupQueue
All Implemented Interfaces:
java.lang.Iterable<Message<?>>, java.util.Collection<Message<?>>, java.util.concurrent.BlockingQueue<Message<?>>, java.util.Queue<Message<?>>

public class MessageGroupQueue
extends java.util.AbstractQueue<Message<?>>
implements java.util.concurrent.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

Constructor Summary
MessageGroupQueue(MessageGroupStore messageGroupStore, java.lang.Object groupId)
           
MessageGroupQueue(MessageGroupStore messageGroupStore, java.lang.Object groupId, int capacity)
           
 
Method Summary
 int drainTo(java.util.Collection<? super Message<?>> c)
           
 int drainTo(java.util.Collection<? super Message<?>> c, int maxElements)
           
 java.util.Iterator<Message<?>> iterator()
           
 boolean offer(Message<?> e)
           
 boolean offer(Message<?> e, long timeout, java.util.concurrent.TimeUnit unit)
           
 Message<?> peek()
           
 Message<?> poll()
           
 Message<?> poll(long timeout, java.util.concurrent.TimeUnit unit)
           
 void put(Message<?> e)
           
 int remainingCapacity()
           
 void setStoreLock(java.lang.Object storeLock)
           
 int size()
           
 Message<?> take()
           
 
Methods inherited from class java.util.AbstractQueue
add, addAll, clear, element, remove
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.BlockingQueue
add, contains, remove
 
Methods inherited from interface java.util.Queue
element, remove
 
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Constructor Detail

MessageGroupQueue

public MessageGroupQueue(MessageGroupStore messageGroupStore,
                         java.lang.Object groupId)

MessageGroupQueue

public MessageGroupQueue(MessageGroupStore messageGroupStore,
                         java.lang.Object groupId,
                         int capacity)
Method Detail

setStoreLock

public void setStoreLock(java.lang.Object storeLock)
Parameters:
storeLock - the storeLock to set

iterator

public java.util.Iterator<Message<?>> iterator()
Specified by:
iterator in interface java.lang.Iterable<Message<?>>
Specified by:
iterator in interface java.util.Collection<Message<?>>
Specified by:
iterator in class java.util.AbstractCollection<Message<?>>

size

public int size()
Specified by:
size in interface java.util.Collection<Message<?>>
Specified by:
size in class java.util.AbstractCollection<Message<?>>

offer

public boolean offer(Message<?> e)
Specified by:
offer in interface java.util.concurrent.BlockingQueue<Message<?>>
Specified by:
offer in interface java.util.Queue<Message<?>>

peek

public Message<?> peek()
Specified by:
peek in interface java.util.Queue<Message<?>>

poll

public Message<?> poll()
Specified by:
poll in interface java.util.Queue<Message<?>>

drainTo

public int drainTo(java.util.Collection<? super Message<?>> c)
Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<Message<?>>

drainTo

public int drainTo(java.util.Collection<? super Message<?>> c,
                   int maxElements)
Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<Message<?>>

offer

public boolean offer(Message<?> e,
                     long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException
Specified by:
offer in interface java.util.concurrent.BlockingQueue<Message<?>>
Throws:
java.lang.InterruptedException

poll

public Message<?> poll(long timeout,
                       java.util.concurrent.TimeUnit unit)
                throws java.lang.InterruptedException
Specified by:
poll in interface java.util.concurrent.BlockingQueue<Message<?>>
Throws:
java.lang.InterruptedException

put

public void put(Message<?> e)
         throws java.lang.InterruptedException
Specified by:
put in interface java.util.concurrent.BlockingQueue<Message<?>>
Throws:
java.lang.InterruptedException

remainingCapacity

public int remainingCapacity()
Specified by:
remainingCapacity in interface java.util.concurrent.BlockingQueue<Message<?>>

take

public Message<?> take()
                throws java.lang.InterruptedException
Specified by:
take in interface java.util.concurrent.BlockingQueue<Message<?>>
Throws:
java.lang.InterruptedException