Class InMemoryQueue

All Implemented Interfaces:
MonitorableQueue, Queue, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class InMemoryQueue extends AbstractQueue implements MonitorableQueue, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
  • Constructor Details

  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • destroy

      public void destroy() throws Exception
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
      Throws:
      Exception
    • poll

      public void poll(Queue.QueueCallback callback)
      Description copied from interface: Queue
      Polls the queue for ready messages.

      Implementations may invoke [callback] any number of times. Some implementations may deliver a maximum of one message per call, others may deliver all ready messages.

      If no messages exist on the queue or all messages have a remaining delay [callback] is not invoked.

      Messages *must* be acknowledged by calling the function passed to [callback] or they will be retried after [ackTimeout]. Acknowledging via a nested callback allows the message to be processed asynchronously.

      Specified by:
      poll in interface Queue
      Parameters:
      callback - invoked with the next message from the queue if there is one and an _acknowledge_ function to call once processing is complete.
    • poll

      public void poll(int maxMessages, Queue.QueueCallback callback)
      Description copied from interface: Queue
      Polls the queue for ready messages, processing up-to [maxMessages].
      Specified by:
      poll in interface Queue
    • push

      public void push(Message message, TemporalAmount delay)
      Description copied from interface: Queue
      Push [message] for delivery after [delay].
      Specified by:
      push in interface Queue
    • retry

      public void retry()
      Description copied from interface: Queue
      Check for any un-acknowledged messages that are overdue and move them back onto the queue.

      This method is not intended to be called by clients directly but typically scheduled in some way.

      Specified by:
      retry in interface Queue
    • clear

      public void clear()
      Description copied from interface: Queue
      Used for testing zombie executions. Wipes all messages from the queue.
      Specified by:
      clear in interface Queue
    • getAckTimeout

      public TemporalAmount getAckTimeout()
      Description copied from interface: Queue
      The expired time after which un-acknowledged messages will be retried.
      Specified by:
      getAckTimeout in interface Queue
    • getDeadMessageHandlers

      public List<Queue.DeadMessageCallback> getDeadMessageHandlers()
      Description copied from interface: Queue
      A handler for messages that have failed to acknowledge delivery more than [Queue.ackTimeout] times.
      Specified by:
      getDeadMessageHandlers in interface Queue
    • canPollMany

      public Boolean canPollMany()
      Description copied from interface: Queue
      Denotes a queue implementation capable of processing multiple messages per poll.
      Specified by:
      canPollMany in interface Queue
    • getPublisher

      public EventPublisher getPublisher()
      Specified by:
      getPublisher in interface MonitorableQueue
    • readState

      public MonitorableQueue.QueueState readState()
      Specified by:
      readState in interface MonitorableQueue
    • containsMessage

      public boolean containsMessage(Predicate<Message> predicate)
      Specified by:
      containsMessage in interface MonitorableQueue