Annotation 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:

  • Topic to get access to the Redis topic
  • Message to 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 by PubSubHeaders
  • @Headers-annotated method argument that must also be assignable to Map for obtaining access to all headers
  • MessageHeaders arguments for obtaining access to all headers
  • MessageHeaderAccessor for 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:
  • Element Details

    • id

      String id
      The unique identifier of the container managing this endpoint.

      If none is specified, an auto-generated one is provided.

      Default:
      ""
    • container

      String container
      The bean name of the RedisMessageListenerContainer to subscribe with.
      Default:
      "redisMessageListenerContainer"
    • value

      @AliasFor("topic") String value
      The destination name for this listener, resolved through a TopicResolver strategy. Alias for topic().
      Default:
      ""
    • topic

      @AliasFor("value") String topic
      The destination name for this listener, resolved through a TopicResolver strategy.
      Default:
      ""
    • consumes

      String consumes
      Configure the primary mapping by MIME type that is consumed by the handler method. Setting consumes defines 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:
      ""