Package org.redisson.api
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
Distributed implementation of
BlockingQueue
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionpollFirstFromAny
(Duration duration, int count, String... queueNames) 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.pollFromAny
(long timeout, TimeUnit unit, String... queueNames) 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.pollFromAnyWithName
(Duration timeout, String... queueNames) 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.pollLastAndOfferFirstTo
(String queueName, long timeout, TimeUnit unit) Retrieves and removes last available tail element of this queue and adds it at the head ofqueueName
, waiting up to the specified wait time if necessary for an element to become available.pollLastFromAny
(Duration duration, int count, String... queueNames) 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.int
subscribeOnElements
(Consumer<V> consumer) Deprecated.int
subscribeOnElements
(Function<V, CompletionStage<Void>> consumer) Subscribes on elements appeared in this queue.takeLastAndOfferFirstTo
(String queueName) Retrieves and removes last available tail element of any queue and adds it at the head ofqueueName
, waiting if necessary for an element to become available in any of defined queues including queue itself.void
unsubscribe
(int listenerId) Un-subscribes defined listener.Methods inherited from interface java.util.concurrent.BlockingQueue
add, contains, drainTo, drainTo, offer, offer, poll, put, remainingCapacity, remove, take
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
Methods inherited from interface org.redisson.api.RBlockingQueueAsync
drainToAsync, drainToAsync, pollAsync, pollFirstFromAnyAsync, pollFromAnyAsync, pollFromAnyWithNameAsync, pollLastAndOfferFirstToAsync, pollLastFromAnyAsync, putAsync, takeAsync, takeLastAndOfferFirstToAsync
Methods inherited from interface org.redisson.api.RCollectionAsync
addAllAsync, addAsync, containsAllAsync, containsAsync, removeAllAsync, removeAsync, retainAllAsync, sizeAsync
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLive
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, remainTimeToLiveAsync
Methods inherited from interface org.redisson.api.RObject
copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
Methods inherited from interface org.redisson.api.RObjectAsync
copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
Methods inherited from interface org.redisson.api.RQueue
addListener, poll, pollLastAndOfferFirstTo, readAll
Methods inherited from interface org.redisson.api.RQueueAsync
addListenerAsync, offerAsync, peekAsync, pollAsync, pollAsync, pollLastAndOfferFirstToAsync, readAllAsync
-
Method Details
-
pollFromAny
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 ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameterqueueNames
- - 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 ofunit
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 upcount
- elements amountqueueNames
- 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 upcount
- elements amountqueueNames
- 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 ofqueueName
, waiting up to the specified wait time if necessary for an element to become available.- Parameters:
queueName
- - names of destination queuetimeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
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
Retrieves and removes last available tail element of any queue and adds it at the head ofqueueName
, 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.UsesubscribeOnElements(Function)
instead.- Parameters:
consumer
- - queue elements listener- Returns:
- listenerId - id of listener
-
subscribeOnElements
Subscribes on elements appeared in this queue. Continuously invokesRBlockingQueueAsync.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
-