Annotation Interface SqsListener


@Target(METHOD) @Retention(RUNTIME) @Documented public @interface SqsListener
Methods with this annotation will be wrapped by a MessageListener or AsyncMessageListener and set to a MessageListenerContainer.

Each method will be handled by a different container instance, created by the specified factory() property. If not specified, a default factory will be looked up in the context.

When used in conjunction with Spring Boot and auto configuration, the framework supplies a default SqsMessageListenerContainerFactory and a SqsAsyncClient, unless such beans are already found in the ApplicationContext.

For more complex configurations, SqsMessageListenerContainerFactory instances can be created and configured. See SqsMessageListenerContainerFactory.builder() for more information on creating and configuring a factory.

Further configuration for containers created using this annotation can be achieved by declaring SqsListenerConfigurer beans.

Methods with this annotation can have flexible signatures, including arguments of the following types:

Method signatures also accept List<Pojo> and ListMessage<Pojo> arguments . Such arguments will configure the container to batch mode. When using List arguments, no other arguments can be provided. Metadata can be retrieved by inspecting the Message instances' MessageHeaders.

To support Acknowledgement and BatchAcknowledgement arguments, the factory used to create the containers must be set to AcknowledgementMode.MANUAL.

Properties in this annotation support property placeholders ("${...}") and SpEL ("#{...}").

Since:
1.1
Author:
Alain Sahli, Matej Nedic, Tomaz Fernandes
See Also:
  • Element Details

    • value

      String[] value
      Array of queue names or urls. Queues declared in the same annotation will be handled by the same MessageListenerContainer.
      Returns:
      list of queue names or urls.
      Default:
      {}
    • queueNames

      @AliasFor("value") String[] queueNames
      Alias for value()
      Returns:
      list of queue names or urls.
      Default:
      {}
    • factory

      String factory
      The MessageListenerContainerFactory bean name to be used to process this endpoint.
      Returns:
      the factory bean name.
      Default:
      ""
    • id

      String id
      An id for the MessageListenerContainer that will be created to handle this endpoint. If none provided a default ID will be created.
      Returns:
      the container id.
      Default:
      ""
    • maxConcurrentMessages

      String maxConcurrentMessages
      The maximum concurrent messages that can be processed simultaneously for each queue. Note that if acknowledgement batching is being used, the actual maximum number of inflight messages might be higher. Default is 10.
      Returns:
      the maximum number of concurrent messages.
      Default:
      ""
    • pollTimeoutSeconds

      String pollTimeoutSeconds
      The maximum number of seconds to wait for messages in a poll to SQS.
      Returns:
      the poll timeout.
      Default:
      ""
    • maxMessagesPerPoll

      String maxMessagesPerPoll
      The maximum amount of time to wait for a poll to SQS. If a value greater than 10 is provided, the result of multiple polls will be combined, which can be useful for ListenerMode.BATCH
      Returns:
      the maximum messages per poll.
      Default:
      ""
    • messageVisibilitySeconds

      String messageVisibilitySeconds
      The message visibility to be applied to messages received from the provided queues. For Standard SQS queues and batch listeners, visibility will be applied at polling. For single message FIFO queues, visibility is changed before each remaining message from the same message group is processed.
      Default:
      ""