public class RedisQueue extends AbstractHookQueue
started
Constructor and Description |
---|
RedisQueue()
Default constructor
|
RedisQueue(redis.clients.jedis.JedisPool pool)
Allow users to provide their own
JedisPool instance |
RedisQueue(WhoasQueueConfig queueConfig)
Create the RedisQueue with valid config
|
Modifier and Type | Method and Description |
---|---|
int |
getSize()
Return the number of elements in the queue
|
void |
pop(QueueAction action)
Performs a blocking pop on the queue and invokes the closure with the
item popped from the queue
If the Closure throws an exception, the dequeued item will be returned
to the tail end of the queue
|
java.lang.Boolean |
push(HookRequest request)
Attempt to insert the request into the queue
If the request cannot be inserted, this method will return false,
otherwise true.
|
void |
start()
Setup the Redis client
|
void |
stop()
Stop the Redis client
|
protected java.lang.Object |
withRedis(RedisQueueAction action)
Allocate redis client from the pool
|
public RedisQueue(WhoasQueueConfig queueConfig)
queueConfig
- necessary configuration to connect to Redispublic RedisQueue()
public RedisQueue(redis.clients.jedis.JedisPool pool)
JedisPool
instancepool
- an already set up poolpublic int getSize() throws java.lang.Exception
getSize
in class AbstractHookQueue
java.lang.Exception
- implementors may throw Exceptionspublic void start()
start
in class AbstractHookQueue
public void stop()
stop
in class AbstractHookQueue
public void pop(QueueAction action) throws java.lang.Exception
pop
in class AbstractHookQueue
action
- a QueueAction
to invokejava.lang.Exception
- the underlying QueueAction
may throw any form of exceptionpublic java.lang.Boolean push(HookRequest request) throws com.fasterxml.jackson.core.JsonProcessingException, java.lang.Exception
push
in class AbstractHookQueue
request
- A HookRequest
to enqueueHookRequest
was successfully added to the queuejava.lang.Exception
- implementors may throw Exceptionscom.fasterxml.jackson.core.JsonProcessingException
protected java.lang.Object withRedis(RedisQueueAction action) throws java.lang.Exception
action
- callback to invoke with a Jedis
object from the
poolObject
up from the RedisQueueAction
java.lang.Exception
- propogates underlying Jedis exceptions