public interface Queue<T>
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Sets a flag and waits for all the running threads to terminate
|
QueueConsumer<T> |
getConsumer()
Getter for the consumer being used
|
Future<Void> |
getFutureForDocumentStateWait(Set<State> state,
String id)
It returns a future that waits for a document to reach a certain state
Note that this works for DONE and FAILED since they are terminal states.
|
Future<Void> |
getFutureForDocumentStateWait(Set<State> state,
String id,
long timeout,
TimeUnit unit,
redis.clients.util.Pool<redis.clients.jedis.Jedis> pool) |
String |
getName()
Getter for the name of the queue
|
Optional<StateInfo> |
getState(String id)
Retrieves the state for the given id
|
java.util.stream.Stream<Optional<ExtendedStateInfo>> |
getStates()
Retrieves all the states.
|
void |
push(T document)
Put a document in the queue
|
void |
pushAndWait(T document,
long waitTimeout,
TimeUnit waitTimeoutUnit)
Same as push but it waits for the state of the document to be DONE i.e.
|
default void |
setState(String id,
State state) |
void |
setState(String id,
State state,
String info)
Sets a state "manually"
|
void |
startConsumer()
Starts the comsumer for this queue.
|
void push(T document)
document - Document to be pushed to the queue. It must be serialisable.void pushAndWait(T document, long waitTimeout, TimeUnit waitTimeoutUnit) throws WaitException
document - Document to be pushed to the queue. It must be serialisable.waitTimeout - Timeout for the wait. A WaitException is thrown when expiredwaitTimeoutUnit - Unit for the timeoutWaitException - Thrown if a timeout occurs while waiting for the consumer to be acknowledged in Redis or if the waitTimeout expiresFuture<Void> getFutureForDocumentStateWait(Set<State> state, String id) throws StateFutureInitializationException
state - Desired stateid - Id of the document we are watchingStateFutureInitializationException - Thrown if it fails to subscribe to the stateFuture<Void> getFutureForDocumentStateWait(Set<State> state, String id, long timeout, TimeUnit unit, redis.clients.util.Pool<redis.clients.jedis.Jedis> pool) throws StateFutureInitializationException
timeout - How long to wait until failing the subscriptionunit - Unit of the timeoutStateFutureInitializationExceptionAlso takes a jedis poolvoid startConsumer()
void close()
throws InterruptedException
InterruptedException - if the operation is interruptedString getName()
default void setState(String id, State state)
setState(String, State, String)void setState(String id, State state, String info)
id - Id of the documentstate - State (e.g. DONE, FAILED)info - Extra info to be stored (e.g. the exception message for the failure)Optional<StateInfo> getState(String id)
id - Id of the documentjava.util.stream.Stream<Optional<ExtendedStateInfo>> getStates()
QueueConsumer<T> getConsumer()
Copyright © 2017. All rights reserved.