Class RedisQueue<ID,​DATA>

    • Constructor Detail

      • RedisQueue

        public RedisQueue()
    • Method Detail

      • getRedisHostAndPort

        public String getRedisHostAndPort()
        Redis host and port scheme (format host:port).
        Returns:
      • setRedisHostAndPort

        public RedisQueue<ID,​DATA> setRedisHostAndPort​(String redisHostAndPort)
        Redis host and port scheme (format host:port).
        Parameters:
        redisHostAndPort -
        Returns:
      • buildJedisConnector

        protected com.github.ddth.commons.redis.JedisConnector buildJedisConnector()
        Build a JedisConnector instance for my own use.
        Specified by:
        buildJedisConnector in class BaseRedisQueue<ID,​DATA>
        Returns:
      • getBinaryJedisCommands

        protected redis.clients.jedis.BinaryJedisCommands getBinaryJedisCommands()
        Get BinaryJedisCommands instance.
        Specified by:
        getBinaryJedisCommands in class BaseRedisQueue<ID,​DATA>
        Returns:
      • closeJedisCommands

        protected void closeJedisCommands​(redis.clients.jedis.BinaryJedisCommands jedisCommands)
        Close the unused BinaryJedisCommands.
        Specified by:
        closeJedisCommands in class BaseRedisQueue<ID,​DATA>
      • remove

        protected boolean remove​(IQueueMessage<ID,​DATA> msg)
        Remove a message completely.

        Implementation note:

        • Message should no longer exist after method call regardless of return value (true or false)
        • In case of error, throws QueueException
        Specified by:
        remove in class BaseRedisQueue<ID,​DATA>
        Returns:
        true if the message has been removed, false means the message does not exist for completely removal
      • storeNew

        protected boolean storeNew​(IQueueMessage<ID,​DATA> msg)
        Store a new message.

        Implementation note:

        • Message's ID must be successfully pushed into the "queue-list" so that the method call is considered successful. If message's id has not pushed to the "queue-list", this method must return false.
        • Caller can retry if method returns false. Implementation's responsibility to ensure message is not duplicated in storage.
        • In case of error, throws QueueException
        Specified by:
        storeNew in class BaseRedisQueue<ID,​DATA>
        Returns:
      • take

        public IQueueMessage<ID,​DATA> take()
                                          throws QueueException.EphemeralIsFull
        Take a message out of queue.

        Implementation flow:

        • Read message from head of queue storage.
        • Write message to ephemeral storage.
        • Remove message from queue storage.

        Note: ephemeral storage implementation is optional, depends on implementation.

        Returns:
        Throws:
        QueueException.EphemeralIsFull - if the ephemeral storage is full