Interface RBlockingQueue<V>

Type Parameters:
V - the type of elements held in this collection
All Superinterfaces:
BlockingQueue<V>, Collection<V>, Iterable<V>, Queue<V>, RBlockingQueueAsync<V>, RCollectionAsync<V>, RExpirable, RExpirableAsync, RObject, RObjectAsync, RQueue<V>, RQueueAsync<V>
All Known Subinterfaces:
RBlockingDeque<V>, RBoundedBlockingQueue<V>, RPriorityBlockingDeque<V>, RPriorityBlockingQueue<V>, RTransferQueue<V>
All Known Implementing Classes:
RedissonBlockingDeque, RedissonBlockingQueue, RedissonBoundedBlockingQueue, RedissonPriorityBlockingDeque, RedissonPriorityBlockingQueue, RedissonTransferQueue

public interface RBlockingQueue<V> extends BlockingQueue<V>, RQueue<V>, RBlockingQueueAsync<V>
Distributed implementation of BlockingQueue
Author:
Nikita Koksharov
  • Method Details

    • pollFromAny

      V pollFromAny(long timeout, TimeUnit unit, String... queueNames) throws InterruptedException
      Retrieves and removes first available head element of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.
      Parameters:
      timeout - how long to wait before giving up, in units of unit
      unit - a TimeUnit determining how to interpret the timeout parameter
      queueNames - - queue names. Queue name itself is always included
      Returns:
      the head of this queue, or null if the specified waiting time elapses before an element is available
      Throws:
      InterruptedException - if interrupted while waiting
    • pollFromAnyWithName

      Entry<String,V> pollFromAnyWithName(Duration timeout, String... queueNames) throws InterruptedException
      Retrieves and removes first available head element of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.
      Parameters:
      timeout - how long to wait before giving up, in units of unit
      queueNames - queue names. Queue name itself is always included
      Returns:
      the head of this queue, or null if the specified waiting time elapses before an element is available
      Throws:
      InterruptedException - if interrupted while waiting
    • pollFirstFromAny

      Map<String,List<V>> pollFirstFromAny(Duration duration, int count, String... queueNames) throws InterruptedException
      Retrieves and removes first available head elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.

      Requires Redis 7.0.0 and higher.

      Parameters:
      duration - how long to wait before giving up
      count - elements amount
      queueNames - name of queues
      Returns:
      the head elements
      Throws:
      InterruptedException
    • pollLastFromAny

      Map<String,List<V>> pollLastFromAny(Duration duration, int count, String... queueNames) throws InterruptedException
      Retrieves and removes first available tail elements of any queue, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.

      Requires Redis 7.0.0 and higher.

      Parameters:
      duration - how long to wait before giving up
      count - elements amount
      queueNames - name of queues
      Returns:
      the tail elements
      Throws:
      InterruptedException
    • pollLastAndOfferFirstTo

      V pollLastAndOfferFirstTo(String queueName, long timeout, TimeUnit unit) throws InterruptedException
      Retrieves and removes last available tail element of this queue and adds it at the head of queueName, waiting up to the specified wait time if necessary for an element to become available.
      Parameters:
      queueName - - names of destination queue
      timeout - how long to wait before giving up, in units of unit
      unit - a TimeUnit determining how to interpret the timeout parameter
      Returns:
      the tail of this queue, or null if the specified waiting time elapses before an element is available
      Throws:
      InterruptedException - if interrupted while waiting
    • takeLastAndOfferFirstTo

      V takeLastAndOfferFirstTo(String queueName) throws InterruptedException
      Retrieves and removes last available tail element of any queue and adds it at the head of queueName, waiting if necessary for an element to become available in any of defined queues including queue itself.
      Parameters:
      queueName - - names of destination queue
      Returns:
      the tail of this queue, or null if the specified waiting time elapses before an element is available
      Throws:
      InterruptedException - if interrupted while waiting
    • subscribeOnElements

      @Deprecated int subscribeOnElements(Consumer<V> consumer)
      Deprecated.
      Parameters:
      consumer - - queue elements listener
      Returns:
      listenerId - id of listener
    • subscribeOnElements

      int subscribeOnElements(Function<V,CompletionStage<Void>> consumer)
      Subscribes on elements appeared in this queue. Continuously invokes RBlockingQueueAsync.takeAsync() method to get a new element.

      NOTE: don't call blocking methods in the elements listener

      Parameters:
      consumer - - queue elements listener
      Returns:
      listenerId - id of listener
    • unsubscribe

      void unsubscribe(int listenerId)
      Un-subscribes defined listener.
      Parameters:
      listenerId - - id of listener