Class JedisKeyedBlockingQueue

java.lang.Object
org.deltafi.common.queue.jedis.JedisKeyedBlockingQueue

public class JedisKeyedBlockingQueue extends Object
A keyed blocking queue based on the Jedis client library for Redis.
  • Constructor Details

    • JedisKeyedBlockingQueue

      public JedisKeyedBlockingQueue(String url, String password, int maxIdle, int maxTotal) throws URISyntaxException
      Constructs a JedisKeyedBlockingQueue.
      Parameters:
      url - the url of the redis server
      password - the password for the redis server
      maxIdle - the maximum number of idle pooled connections to the redis server
      maxTotal - 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:
      URISyntaxException - if the provided url is not valid
  • Method Details

    • put

      public void put(String key, Object object) throws com.fasterxml.jackson.core.JsonProcessingException
      Puts an object into the queue.
      Parameters:
      key - the key for the object
      object - the object
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if the object cannot be converted to a JSON string
    • drop

      public void drop(List<String> keys)
      Drop all queues in key list.
      Parameters:
      keys - list of keys
    • put

      public void put(List<org.apache.commons.lang3.tuple.Pair<String,Object>> items) throws com.fasterxml.jackson.core.JsonProcessingException, redis.clients.jedis.exceptions.JedisConnectionException
      Puts 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 not
      redis.clients.jedis.exceptions.JedisConnectionException
    • setHeartbeat

      public void setHeartbeat(String key)
      Publish a heartbeat in the form of a timestamp
      Parameters:
      key - the name of the component publishing the heartbeat
    • take

      public <T> T take(String key, Class<T> objectClass) throws com.fasterxml.jackson.core.JsonProcessingException, redis.clients.jedis.exceptions.JedisConnectionException
      Takes 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 object
      objectClass - 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 type
      redis.clients.jedis.exceptions.JedisConnectionException