Class RedisMonitorConnection

java.lang.Object
com.blackrook.redis.RedisConnectionAbstract
com.blackrook.redis.RedisMonitorConnection
All Implemented Interfaces:
AutoCloseable

public class RedisMonitorConnection extends RedisConnectionAbstract
A connection to Redis that sends MONITOR to the database and constantly fires events on reception of responses. This connection cannot have any commands issued to it.
Author:
Matthew Tropiano
  • Constructor Details

    • RedisMonitorConnection

      public RedisMonitorConnection(RedisMonitorListener... listeners) throws IOException
      Creates an open connection to localhost, port 6379, the default Redis port.
      Parameters:
      listeners - the listeners to add to this monitor connection.
      Throws:
      IOException - if an I/O error occurs when creating the socket.
      UnknownHostException - if the IP address of the host could not be determined.
      SecurityException - if a security manager exists and doesn't allow the connection to be made.
    • RedisMonitorConnection

      public RedisMonitorConnection(String host, int port, RedisMonitorListener... listeners) throws IOException
      Creates an open connection.
      Parameters:
      host - the server hostname or address.
      port - the server connection port.
      listeners - the listeners to add to this monitor connection.
      Throws:
      IOException - if an I/O error occurs when creating the socket.
      UnknownHostException - if the IP address of the host could not be determined.
      SecurityException - if a security manager exists and doesn't allow the connection to be made.
    • RedisMonitorConnection

      public RedisMonitorConnection(String host, int port, String password, RedisMonitorListener... listeners) throws IOException
      Creates an open connection.
      Parameters:
      host - the server hostname or address.
      port - the server connection port.
      password - the server database password.
      listeners - the listeners to add to this monitor connection.
      Throws:
      IOException - if an I/O error occurs when creating the socket.
      UnknownHostException - if the IP address of the host could not be determined.
      SecurityException - if a security manager exists and doesn't allow the connection to be made.
      RedisException - if the password in the server information is incorrect.
    • RedisMonitorConnection

      public RedisMonitorConnection(RedisInfo info, RedisMonitorListener... listeners) throws IOException
      Creates an open connection.
      Parameters:
      info - the RedisInfo class detailing a connection's parameters.
      listeners - the listeners to add to this monitor connection.
      Throws:
      IOException - if an I/O error occurs when creating the socket.
      UnknownHostException - if the IP address of the host could not be determined.
      SecurityException - if a security manager exists and doesn't allow the connection to be made.
      RedisException - if the password in the server information is incorrect.
  • Method Details

    • addListener

      public void addListener(RedisMonitorListener... listeners)
      Adds RedisMonitorListeners to this connection. All listeners on this connection are alerted when a message is received.
      Parameters:
      listeners - the listeners to add.
    • removeListeners

      public void removeListeners(RedisMonitorListener... listeners)
      Removes RedisSubscriptionListeners from this connection.
      Parameters:
      listeners - the listeners to remove.
    • fireOnMonitorEvent

      protected void fireOnMonitorEvent(RedisMonitorEvent event)
      Fires an event to listeners when this connection receives a monitor event.
      Parameters:
      event - the event to send to the listeners.