Class AbstractMessageListenerContainer<T,O extends ContainerOptions<O,B>,B extends ContainerOptionsBuilder<B,O>>

java.lang.Object
io.awspring.cloud.sqs.listener.AbstractMessageListenerContainer<T,O,B>
Type Parameters:
T - the Message type to be consumed by the AbstractMessageListenerContainer
All Implemented Interfaces:
MessageListenerContainer<T>, Lifecycle, Phased, SmartLifecycle
Direct Known Subclasses:
AbstractPipelineMessageListenerContainer

public abstract class AbstractMessageListenerContainer<T,O extends ContainerOptions<O,B>,B extends ContainerOptionsBuilder<B,O>> extends Object implements MessageListenerContainer<T>
Base implementation for MessageListenerContainer with SmartLifecycle and component management capabilities.
Since:
3.0
Author:
Tomaz Fernandes
  • Constructor Details

    • AbstractMessageListenerContainer

      protected AbstractMessageListenerContainer(O containerOptions)
      Create an instance with the provided ContainerOptions
      Parameters:
      containerOptions - the options instance.
  • Method Details

    • setId

      public void setId(String id)
      Set the id for this container instance.
      Specified by:
      setId in interface MessageListenerContainer<T>
      Parameters:
      id - the id.
    • setErrorHandler

      public void setErrorHandler(ErrorHandler<T> errorHandler)
      Set the ErrorHandler instance to be used by this container. The component will be adapted to an AsyncErrorHandler.
      Parameters:
      errorHandler - the instance.
    • setErrorHandler

      public void setErrorHandler(AsyncErrorHandler<T> errorHandler)
      Set the AsyncErrorHandler instance to be used by this container.
      Parameters:
      errorHandler - the instance.
    • addMessageInterceptor

      public void addMessageInterceptor(MessageInterceptor<T> messageInterceptor)
      Add a collection of interceptors that will intercept the message before processing. Interceptors are executed sequentially and in order.
      Parameters:
      messageInterceptor - the interceptor instances.
    • addMessageInterceptor

      public void addMessageInterceptor(AsyncMessageInterceptor<T> messageInterceptor)
      Add an interceptor that will intercept the message before processing. Interceptors are executed sequentially and in order.
      Parameters:
      messageInterceptor - the interceptor instances.
    • setMessageListener

      public void setMessageListener(MessageListener<T> messageListener)
      Description copied from interface: MessageListenerContainer
      Set the listener to be used to process messages.
      Specified by:
      setMessageListener in interface MessageListenerContainer<T>
      Parameters:
      messageListener - the instance.
    • setAsyncMessageListener

      public void setAsyncMessageListener(AsyncMessageListener<T> asyncMessageListener)
      Description copied from interface: MessageListenerContainer
      Set the listener to be used to receive messages.
      Specified by:
      setAsyncMessageListener in interface MessageListenerContainer<T>
      Parameters:
      asyncMessageListener - the message listener instance.
    • setAcknowledgementResultCallback

      public void setAcknowledgementResultCallback(AsyncAcknowledgementResultCallback<T> acknowledgementResultCallback)
      Set the AsyncAcknowledgementResultCallback instance to be used by this container.
      Parameters:
      acknowledgementResultCallback - the instance.
    • setAcknowledgementResultCallback

      public void setAcknowledgementResultCallback(AcknowledgementResultCallback<T> acknowledgementResultCallback)
      Set the AcknowledgementResultCallback instance to be used by this container.
      Parameters:
      acknowledgementResultCallback - the instance.
    • setComponentFactories

      public void setComponentFactories(Collection<ContainerComponentFactory<T,O>> containerComponentFactories)
    • setPhase

      public void setPhase(int phase)
      Set the phase for the SmartLifecycle for this container instance.
      Parameters:
      phase - the phase.
    • setPayloadDeserializationType

      public void setPayloadDeserializationType(@Nullable Class<?> payloadDeserializationType)
      Set the target type for payload deserialization. When set, messages will be deserialized to this type at the MessageSource before being passed to the listener.

      Since 4.0.0, this type is typically inferred automatically from the @SqsListener method signature when using @SqsListener annotations, but can also be set manually for programmatic container configuration.

      Note on precedence: Payload type mappers on the converter take precedence over the type manually set by this method.

      Parameters:
      payloadDeserializationType - the target type for deserialization
      See Also:
    • configure

      public void configure(Consumer<B> options)
      Returns the ContainerOptions instance for this container. Changed options will take effect on container restart.
    • getContainerOptions

      public O getContainerOptions()
    • getContainerComponentFactories

      public Collection<ContainerComponentFactory<T,O>> getContainerComponentFactories()
      Return the ContainerComponentFactory instances to be used for creating this container's components.
      Returns:
      the instances.
    • getMessageListener

      public AsyncMessageListener<T> getMessageListener()
      Return the AsyncMessageListener instance used by this container.
      Returns:
      the instance.
    • getErrorHandler

      public AsyncErrorHandler<T> getErrorHandler()
      Return the AsyncErrorHandler instance used by this container.
      Returns:
      the instance.
    • getMessageInterceptors

      public Collection<AsyncMessageInterceptor<T>> getMessageInterceptors()
      Return the AsyncMessageInterceptor instances used by this container.
      Returns:
      the instances.
    • getAcknowledgementResultCallback

      public AsyncAcknowledgementResultCallback<T> getAcknowledgementResultCallback()
      Return the AcknowledgementResultCallback instance used by this container.
      Returns:
      the instance.
    • getPayloadDeserializationType

      public @Nullable Class<?> getPayloadDeserializationType()
      Return the target type for payload deserialization, or null if not set.
      Returns:
      the payload deserialization type.
    • getId

      public String getId()
      Description copied from interface: MessageListenerContainer
      Get the container id.
      Specified by:
      getId in interface MessageListenerContainer<T>
      Returns:
      the id.
    • setQueueNames

      public void setQueueNames(Collection<String> queueNames)
      Set the queue logical names that will be handled by the container. Required for container start.
      Parameters:
      queueNames - the queue names.
    • setQueueNames

      public void setQueueNames(String... queueNames)
      Set the queue logical names that will be handled by the container. Required for container start.
      Parameters:
      queueNames - the queue names.
    • getQueueNames

      public Collection<String> getQueueNames()
      Return the queue names assigned to this container.
      Returns:
      the queue names.
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface Lifecycle
    • getPhase

      public int getPhase()
      Specified by:
      getPhase in interface Phased
      Specified by:
      getPhase in interface SmartLifecycle
    • isAutoStartup

      public boolean isAutoStartup()
      Specified by:
      isAutoStartup in interface SmartLifecycle
    • start

      public void start()
      Specified by:
      start in interface Lifecycle
    • doStart

      protected void doStart()
    • stop

      public void stop()
      Specified by:
      stop in interface Lifecycle
    • doStop

      protected void doStop()