Package org.deltafi.common.queue.jedis
Class JedisKeyedBlockingQueue
- java.lang.Object
-
- org.deltafi.common.queue.jedis.JedisKeyedBlockingQueue
-
public class JedisKeyedBlockingQueue extends java.lang.ObjectA keyed blocking queue based on the Jedis client library for Redis.
-
-
Constructor Summary
Constructors Constructor Description JedisKeyedBlockingQueue(java.lang.String url, java.lang.String password, int maxIdle, int maxTotal)Constructs a JedisKeyedBlockingQueue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddrop(java.util.List<java.lang.String> keys)Drop all queues in key list.voidput(java.lang.String key, java.lang.Object object)Puts an object into the queue.voidput(java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Object>> items)Puts multiple objects into the queue.<T> Ttake(java.lang.String key, java.lang.Class<T> objectClass)Takes an object out of the queue.
-
-
-
Constructor Detail
-
JedisKeyedBlockingQueue
public JedisKeyedBlockingQueue(java.lang.String url, java.lang.String password, int maxIdle, int maxTotal) throws java.net.URISyntaxExceptionConstructs a JedisKeyedBlockingQueue.- Parameters:
url- the url of the redis serverpassword- the password for the redis servermaxIdle- the maximum number of idle pooled connections to the redis servermaxTotal- the maximum number of pooled connections to the redis server. This should be set higher than the expected number of keys in the queue.- Throws:
java.net.URISyntaxException- if the provided url is not valid
-
-
Method Detail
-
put
public void put(java.lang.String key, java.lang.Object object) throws com.fasterxml.jackson.core.JsonProcessingExceptionPuts an object into the queue.- Parameters:
key- the key for the objectobject- the object- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if the object cannot be converted to a JSON string
-
drop
public void drop(java.util.List<java.lang.String> keys)
Drop all queues in key list.- Parameters:
keys- list of keys
-
put
public void put(java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Object>> items) throws com.fasterxml.jackson.core.JsonProcessingException, redis.clients.jedis.exceptions.JedisConnectionExceptionPuts multiple objects into the queue.- Parameters:
items- a list of key/object pairss to put into the queue- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if any object in the map cannot be converted to a JSON string. Objects retrieved from objectMap before the exception occurred will be placed in the queue, all others will notredis.clients.jedis.exceptions.JedisConnectionException
-
take
public <T> T take(java.lang.String key, java.lang.Class<T> objectClass) throws com.fasterxml.jackson.core.JsonProcessingException, redis.clients.jedis.exceptions.JedisConnectionExceptionTakes an object out of the queue.This method will block until an object for the provided key is available. When multiple objects are available for the provided key, the earliest one put into the queue is retrieved.
- Type Parameters:
T- the type of the class of the object- Parameters:
key- the key for the objectobjectClass- the class of the object- Returns:
- the object
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if the JSON string retrieved from the queue cannot be converted to the provided typeredis.clients.jedis.exceptions.JedisConnectionException
-
-