| Constructor and Description |
|---|
Redisq(String name,
java.time.Duration timeout,
java.time.Duration ttlStateInfo,
java.time.Duration lockTime,
java.time.Duration discardTime,
java.util.function.Consumer<T> consumer,
Class<T> klass,
redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool,
ExecutorService threadPool,
com.codahale.metrics.MetricRegistry metricRegistry) |
| 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
|
Names |
getNames() |
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 dummyObject,
long waitTimeout,
TimeUnit waitTimeoutUnit)
Same as push but it waits for the state of the document to be DONE i.e.
|
void |
setState(redis.clients.jedis.Jedis jedis,
long timestampMs,
String id,
State state,
String info) |
void |
setState(String id,
State state,
String info)
Sets a state "manually"
|
void |
startConsumer()
Starts the comsumer for this queue.
|
public Redisq(String name, java.time.Duration timeout, java.time.Duration ttlStateInfo, java.time.Duration lockTime, java.time.Duration discardTime, java.util.function.Consumer<T> consumer, Class<T> klass, redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool, ExecutorService threadPool, com.codahale.metrics.MetricRegistry metricRegistry)
public void push(T document)
Queuepublic void startConsumer()
QueuestartConsumer in interface Queue<T extends Document>public Future<Void> getFutureForDocumentStateWait(Set<State> state, String id) throws StateFutureInitializationException
QueuegetFutureForDocumentStateWait in interface Queue<T extends Document>state - Desired stateid - Id of the document we are watchingStateFutureInitializationException - Thrown if it fails to subscribe to the statepublic Future<Void> getFutureForDocumentStateWait(Set<State> state, String id, long timeout, TimeUnit unit, redis.clients.util.Pool<redis.clients.jedis.Jedis> pool) throws StateFutureInitializationException
getFutureForDocumentStateWait in interface Queue<T extends Document>timeout - How long to wait until failing the subscriptionunit - Unit of the timeoutStateFutureInitializationExceptionAlso takes a jedis poolpublic void setState(String id, State state, String info)
Queuepublic void setState(redis.clients.jedis.Jedis jedis,
long timestampMs,
String id,
State state,
String info)
public Optional<StateInfo> getState(String id)
Queuepublic java.util.stream.Stream<Optional<ExtendedStateInfo>> getStates()
Queuepublic void close()
throws InterruptedException
Queueclose in interface Queue<T extends Document>InterruptedException - if the operation is interruptedpublic String getName()
Queuepublic QueueConsumer<T> getConsumer()
QueuegetConsumer in interface Queue<T extends Document>public void pushAndWait(T dummyObject, long waitTimeout, TimeUnit waitTimeoutUnit) throws WaitException
QueuepushAndWait in interface Queue<T extends Document>dummyObject - 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 expirespublic Names getNames()
Copyright © 2017. All rights reserved.