Class JedisKeyedBlockingQueue


  • public class JedisKeyedBlockingQueue
    extends java.lang.Object
    A 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
      void drop​(java.util.List<java.lang.String> keys)
      Drop all queues in key list.
      void put​(java.lang.String key, java.lang.Object object)
      Puts an object into the queue.
      void put​(java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.Object>> items)
      Puts multiple objects into the queue.
      <T> T take​(java.lang.String key, java.lang.Class<T> objectClass)
      Takes an object out of the queue.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JedisKeyedBlockingQueue

        public JedisKeyedBlockingQueue​(java.lang.String url,
                                       java.lang.String password,
                                       int maxIdle,
                                       int maxTotal)
                                throws java.net.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:
        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.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​(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.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
      • take

        public <T> T take​(java.lang.String key,
                          java.lang.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