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 Summary
ConstructorsConstructorDescriptionKeyspaceEventMessageListener
(RedisMessageListenerContainer listenerContainer) Creates newKeyspaceEventMessageListener
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
destroy()
protected abstract void
doHandleMessage
(Message message) Handle the actual messageprotected void
doRegister
(RedisMessageListenerContainer container) Register instance within the container.void
init()
Initialize the message listener by writing requried redis config for notify-keyspace-events and registering the listener within the container.void
Callback for processing received objects through Redis.void
setKeyspaceNotificationsConfigParameter
(String keyspaceNotificationsConfigParameter) Set the configuration string to use for notify-keyspace-events.
-
Constructor Details
-
KeyspaceEventMessageListener
Creates newKeyspaceEventMessageListener
.- Parameters:
listenerContainer
- must not be null.
-
-
Method Details
-
setKeyspaceNotificationsConfigParameter
public void setKeyspaceNotificationsConfigParameter(@Nullable String keyspaceNotificationsConfigParameter) Set the configuration string to use for notify-keyspace-events.- Parameters:
keyspaceNotificationsConfigParameter
- can be null.- Since:
- 1.8
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
destroy
- Specified by:
destroy
in interfaceDisposableBean
- Throws:
Exception
-
onMessage
Description copied from interface:MessageListener
Callback for processing received objects through Redis.- Specified by:
onMessage
in interfaceMessageListener
- Parameters:
message
- message must not be null.pattern
- pattern matching the channel (if specified) - can be null.
-
doHandleMessage
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
Register instance within the container.- Parameters:
container
- never null.
-