Package org.redisson.api
Interface RBlockingQueueRx<V>
- Type Parameters:
V
- the type of elements held in this collection
- All Superinterfaces:
RCollectionRx<V>
,RExpirableRx
,RObjectRx
,RQueueRx<V>
- All Known Subinterfaces:
RBlockingDequeRx<V>
,RTransferQueueRx<V>
RxJava2 interface for BlockingQueue
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Single
<Integer> drainTo
(Collection<? super V> c) Removes all available elements from this queue and adds them to the given collection in async mode.io.reactivex.rxjava3.core.Single
<Integer> drainTo
(Collection<? super V> c, int maxElements) Removes at most the given number of available elements from this queue and adds them to the given collection in async mode.io.reactivex.rxjava3.core.Maybe
<V> Retrieves and removes the head of this queue in async mode, waiting up to the specified wait time if necessary for an element to become available.pollFirstFromAny
(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.io.reactivex.rxjava3.core.Maybe
<V> 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 own.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.io.reactivex.rxjava3.core.Maybe
<V> 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.io.reactivex.rxjava3.core.Completable
Inserts the specified element into this queue in async mode, waiting if necessary for space to become available.io.reactivex.rxjava3.core.Single
<V> take()
Retrieves and removes the head of this queue in async mode, waiting if necessary until an element becomes available.io.reactivex.rxjava3.core.Flowable
<V> Retrieves and removes continues stream of elements from the head of this queue.io.reactivex.rxjava3.core.Single
<V> 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.Methods inherited from interface org.redisson.api.RCollectionRx
add, addAll, addAll, contains, containsAll, iterator, remove, removeAll, retainAll, size
Methods inherited from interface org.redisson.api.RExpirableRx
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLive
Methods inherited from interface org.redisson.api.RObjectRx
copy, copy, copy, copyAndReplace, copyAndReplace, 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.RQueueRx
addListener, offer, peek, poll, poll, pollLastAndOfferFirstTo, readAll
-
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 own.- Parameters:
timeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameterqueueNames
- - names of queue- Returns:
- Flowable object with the head of this queue, or
null
if the specified waiting time elapses before an element is available
-
pollFromAnyWithName
io.reactivex.rxjava3.core.Maybe<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
io.reactivex.rxjava3.core.Maybe<Map<String,List<V>>> pollFirstFromAny(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.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
-
pollLastFromAny
io.reactivex.rxjava3.core.Maybe<Map<String,List<V>>> 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.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
-
drainTo
Removes at most the given number of available elements from this queue and adds them to the given collection in async mode. A failure encountered while attempting to add elements to collectionc
may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result inIllegalArgumentException
. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.- Parameters:
c
- the collection to transfer elements intomaxElements
- the maximum number of elements to transfer- Returns:
- the number of elements transferred
- Throws:
UnsupportedOperationException
- if addition of elements is not supported by the specified collectionClassCastException
- if the class of an element of this queue prevents it from being added to the specified collectionNullPointerException
- if the specified collection is nullIllegalArgumentException
- if the specified collection is this queue, or some property of an element of this queue prevents it from being added to the specified collection
-
drainTo
Removes all available elements from this queue and adds them to the given collection in async mode. This operation may be more efficient than repeatedly polling this queue. A failure encountered while attempting to add elements to collectionc
may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result inIllegalArgumentException
. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.- Parameters:
c
- the collection to transfer elements into- Returns:
- the number of elements transferred
- Throws:
UnsupportedOperationException
- if addition of elements is not supported by the specified collectionClassCastException
- if the class of an element of this queue prevents it from being added to the specified collectionNullPointerException
- if the specified collection is nullIllegalArgumentException
- if the specified collection is this queue, or some property of an element of this queue prevents it from being added to the specified collection
-
pollLastAndOfferFirstTo
io.reactivex.rxjava3.core.Maybe<V> 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.- 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
-
poll
Retrieves and removes the head of this queue in async mode, waiting up to the specified wait time if necessary for an element to become available.- Parameters:
timeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the head of this queue, or
null
if the specified waiting time elapses before an element is available
-
take
io.reactivex.rxjava3.core.Single<V> take()Retrieves and removes the head of this queue in async mode, waiting if necessary until an element becomes available.- Returns:
- the head of this queue
-
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
-
put
Inserts the specified element into this queue in async mode, waiting if necessary for space to become available.- Parameters:
e
- the element to add- Returns:
- void
- Throws:
ClassCastException
- if the class of the specified element prevents it from being added to this queueNullPointerException
- if the specified element is nullIllegalArgumentException
- if some property of the specified element prevents it from being added to this queue
-
takeElements
io.reactivex.rxjava3.core.Flowable<V> takeElements()Retrieves and removes continues stream of elements from the head of this queue. Waits for next element become available.- Returns:
- stream of elements
-