Annotation Interface RedisListener
@Target({METHOD,ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
@Repeatable(RedisListeners.class)
@MessageMapping
public @interface RedisListener
Annotation that marks a method to be the target of a Redis Pub/Sub message listener on the specified
topic().
The container() identifies the RedisMessageListenerContainer
to subscribe with. If not set, a default container is assumed to be available with a bean name of
redisMessageListenerContainer unless an explicit default has been provided through configuration.
Processing of @RedisListener annotations is performed by registering a
RedisListenerAnnotationBeanPostProcessor. This can be done manually or, more conveniently, through the
@EnableRedisListeners annotation.
Annotated Redis listener methods are allowed to have flexible signatures similar to what MessageMapping
provides:
Topicto get access to the Redis topicMessageto use Spring's messaging abstraction@Payload-annotated method arguments, including support for validation@Header-annotated method arguments to extract specific header values, including Redis headers defined byPubSubHeaders@Headers-annotated method argument that must also be assignable toMapfor obtaining access to all headersMessageHeadersarguments for obtaining access to all headersMessageHeaderAccessorfor convenient access to all method arguments
This annotation can be used as a repeatable annotation.
This annotation may be used as a meta-annotation to create custom composed annotations with attribute overrides.
- Since:
- 4.1
- Author:
- Ilyass Bougati, Mark Paluch
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionConfigure the primary mapping by MIME type that is consumed by the handler method.The bean name of theRedisMessageListenerContainerto subscribe with.The unique identifier of the container managing this endpoint.The destination name for this listener, resolved through aTopicResolverstrategy.The destination name for this listener, resolved through aTopicResolverstrategy.
-
Element Details
-
id
String idThe unique identifier of the container managing this endpoint.If none is specified, an auto-generated one is provided.
- Default:
""
-
container
String containerThe bean name of theRedisMessageListenerContainerto subscribe with.- Default:
"redisMessageListenerContainer"
-
value
The destination name for this listener, resolved through aTopicResolverstrategy. Alias fortopic().- Default:
""
-
topic
The destination name for this listener, resolved through aTopicResolverstrategy.- Default:
""
-
consumes
String consumesConfigure the primary mapping by MIME type that is consumed by the handler method. Settingconsumesdefines the message content type as Redis Pub/Sub messages do not feature headers to indicate a content type towards message converter selection. Examples:consumes = "text/plain" consumes = "application/*"
- See Also:
- Default:
""
-