Interface Queue<T>

All Superinterfaces:
Measureable<Queue.Metrics>
All Known Implementing Classes:
DefaultQueue

public interface Queue<T> extends Measureable<Queue.Metrics>
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Receives a message from the queue, waiting if necessary.
    receive(Duration timeout)
    Receives a message from the queue, waiting if necessary.
    Attempts to receive a message from the queue.

    Methods inherited from interface io.aleph0.yap.core.Measureable

    checkMetrics, flushMetrics
  • Method Details

    • tryReceive

      T tryReceive()
      Attempts to receive a message from the queue. This method will return immediately, even if there are no messages available in the queue. Returns null if the queue is empty, whethere it is closed or not, so users must not conclude that the queue is closed and drained from this method returning null.
      Returns:
      the message received from the queue, or null if the queue is empty
    • receive

      T receive(Duration timeout) throws InterruptedException, TimeoutException
      Receives a message from the queue, waiting if necessary. This method will block until a message is received from the queue or the timeout expires. If the queue is closed and drained, this method will return null. Users may conclude that the queue is closed and drained from this method returning null.
      Parameters:
      timeout - the maximum time to wait for a message to be received
      Returns:
      the message received from the queue, or null if the queue is closed and drained
      Throws:
      InterruptedException - if the thread is interrupted while waiting
      TimeoutException - if the wait times out before a message is received
    • receive

      T receive() throws InterruptedException
      Receives a message from the queue, waiting if necessary. This method will block until a message is received from the queue. If the queue is closed and drained, this method will return null. Users may conclude that the queue is closed and drained from this method returning null.
      Returns:
      the message received from the queue, or null if the queue is closed and drained
      Throws:
      InterruptedException - if the thread is interrupted while waiting
    • isDrained

      boolean isDrained()