Class KeyspaceEventMessageListener

java.lang.Object
org.springframework.data.redis.listener.KeyspaceEventMessageListener
All Implemented Interfaces:
DisposableBean, InitializingBean, MessageListener
Direct Known Subclasses:
KeyExpirationEventMessageListener

public abstract class KeyspaceEventMessageListener extends Object implements MessageListener, InitializingBean, DisposableBean
Base MessageListener implementation for listening to Redis keyspace notifications.
Since:
1.7
Author:
Christoph Strobl, Mark Paluch
  • Constructor Details

  • Method Details

    • onMessage

      public void onMessage(Message message, @Nullable byte[] pattern)
      Description copied from interface: MessageListener
      Callback for processing received objects through Redis.
      Specified by:
      onMessage in interface MessageListener
      Parameters:
      message - message must not be null.
      pattern - pattern matching the channel (if specified) - can be null.
    • doHandleMessage

      protected abstract void doHandleMessage(Message message)
      Handle the actual message
      Parameters:
      message - never null.
    • init

      public void init()
      Initialize the message listener by writing requried redis config for notify-keyspace-events and registering the listener within the container.
    • doRegister

      protected void doRegister(RedisMessageListenerContainer container)
      Register instance within the container.
      Parameters:
      container - never null.
    • destroy

      public void destroy() throws Exception
      Specified by:
      destroy in interface DisposableBean
      Throws:
      Exception
    • setKeyspaceNotificationsConfigParameter

      public void setKeyspaceNotificationsConfigParameter(String keyspaceNotificationsConfigParameter)
      Set the configuration string to use for notify-keyspace-events.
      Parameters:
      keyspaceNotificationsConfigParameter - can be null.
      Since:
      1.8
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface InitializingBean
      Throws:
      Exception