Class MessageGroupQueue

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

public class MessageGroupQueue extends AbstractQueue<org.springframework.messaging.Message<?>> implements BlockingQueue<org.springframework.messaging.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 Details

  • Method Details

    • setPriority

      public 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

      public Iterator<org.springframework.messaging.Message<?>> iterator()
      Specified by:
      iterator in interface Collection<org.springframework.messaging.Message<?>>
      Specified by:
      iterator in interface Iterable<org.springframework.messaging.Message<?>>
      Specified by:
      iterator in class AbstractCollection<org.springframework.messaging.Message<?>>
    • getMessageGroupStore

      protected BasicMessageGroupStore getMessageGroupStore()
      Get the store.
      Returns:
      the store.
      Since:
      5.0.11
    • getStoreLock

      protected Lock getStoreLock()
      Get the store lock.
      Returns:
      the lock.
      Since:
      5.0.11
    • getMessageStoreNotFull

      protected Condition getMessageStoreNotFull()
      Get the not full condition.
      Returns:
      the condition.
      Since:
      5.0.11
    • getMessageStoreNotEmpty

      protected Condition getMessageStoreNotEmpty()
      Get the not empty condition.
      Returns:
      the condition.
      Since:
      5.0.11
    • size

      public int size()
      Specified by:
      size in interface Collection<org.springframework.messaging.Message<?>>
      Specified by:
      size in class AbstractCollection<org.springframework.messaging.Message<?>>
    • peek

      public org.springframework.messaging.Message<?> peek()
      Specified by:
      peek in interface Queue<org.springframework.messaging.Message<?>>
    • poll

      public org.springframework.messaging.Message<?> poll(long timeout, TimeUnit unit) throws InterruptedException
      Specified by:
      poll in interface BlockingQueue<org.springframework.messaging.Message<?>>
      Throws:
      InterruptedException
    • poll

      public org.springframework.messaging.Message<?> poll()
      Specified by:
      poll in interface Queue<org.springframework.messaging.Message<?>>
    • drainTo

      public int drainTo(Collection<? super org.springframework.messaging.Message<?>> c)
      Specified by:
      drainTo in interface BlockingQueue<org.springframework.messaging.Message<?>>
    • drainTo

      public int drainTo(Collection<? super org.springframework.messaging.Message<?>> collection, int maxElements)
      Specified by:
      drainTo in interface BlockingQueue<org.springframework.messaging.Message<?>>
    • offer

      public boolean offer(org.springframework.messaging.Message<?> message)
      Specified by:
      offer in interface BlockingQueue<org.springframework.messaging.Message<?>>
      Specified by:
      offer in interface Queue<org.springframework.messaging.Message<?>>
    • offer

      public boolean offer(org.springframework.messaging.Message<?> message, long timeout, TimeUnit unit) throws InterruptedException
      Specified by:
      offer in interface BlockingQueue<org.springframework.messaging.Message<?>>
      Throws:
      InterruptedException
    • put

      public void put(org.springframework.messaging.Message<?> message) throws InterruptedException
      Specified by:
      put in interface BlockingQueue<org.springframework.messaging.Message<?>>
      Throws:
      InterruptedException
    • remainingCapacity

      public int remainingCapacity()
      Specified by:
      remainingCapacity in interface BlockingQueue<org.springframework.messaging.Message<?>>
    • take

      public org.springframework.messaging.Message<?> take() throws InterruptedException
      Specified by:
      take in interface BlockingQueue<org.springframework.messaging.Message<?>>
      Throws:
      InterruptedException
    • getMessages

      protected Collection<org.springframework.messaging.Message<?>> getMessages()
    • stream

      public Stream<org.springframework.messaging.Message<?>> stream()
      Specified by:
      stream in interface Collection<org.springframework.messaging.Message<?>>
    • doPoll

      protected org.springframework.messaging.Message<?> doPoll()
      It is assumed that the 'storeLock' is being held by the caller, otherwise IllegalMonitorStateException may be thrown.
      Returns:
      a message // TODO @Nullable
    • doOffer

      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.
      Parameters:
      message - the message to offer.
      Returns:
      true if offered.