Class StreamListenerContainer

java.lang.Object
org.springframework.amqp.rabbit.connection.RabbitAccessor
org.springframework.amqp.rabbit.listener.ObservableListenerContainer
org.springframework.rabbit.stream.listener.StreamListenerContainer
All Implemented Interfaces:
org.springframework.amqp.rabbit.listener.MessageListenerContainer, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class StreamListenerContainer extends org.springframework.amqp.rabbit.listener.ObservableListenerContainer
A listener container for RabbitMQ Streams.
Since:
2.4
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.springframework.core.log.LogAccessor
     

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors
    Constructor
    Description
    StreamListenerContainer(com.rabbitmq.stream.Environment environment)
    Construct an instance using the provided environment.
    StreamListenerContainer(com.rabbitmq.stream.Environment environment, com.rabbitmq.stream.Codec codec)
    Construct an instance using the provided environment and codec.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
     
    Get a StreamMessageConverter used to convert a Message to a Message.
    boolean
     
    boolean
     
    void
    setAdviceChain(org.aopalliance.aop.Advice... advices)
    Set an advice chain to apply to the listener.
    void
    setAutoStartup(boolean autoStart)
     
    void
    Customize the consumer builder before it is built.
    void
    Set a RabbitStreamListenerObservationConvention; used to add additional key/values to observations when using a StreamMessageListener.
    void
    setQueueNames(String... queueNames)
    Mutually exclusive with superStream(String, String).
    void
    Set a StreamMessageConverter used to convert a Message to a Message.
    void
    setupMessageListener(org.springframework.amqp.core.MessageListener messageListener)
     
    void
     
    void
     
    void
    superStream(String streamName, String name)
    Enable Single Active Consumer on a Super Stream, with one consumer.
    void
    superStream(String streamName, String name, int consumers)
    Enable Single Active Consumer on a Super Stream with the provided number of consumers.

    Methods inherited from class org.springframework.amqp.rabbit.listener.ObservableListenerContainer

    checkMicrometer, checkObservation, destroy, getApplicationContext, getBeanName, getListenerId, getMicrometerHolder, setApplicationContext, setBeanName, setListenerId, setMicrometerEnabled, setMicrometerTags, setObservationEnabled

    Methods inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor

    convertRabbitAccessException, createConnection, getChannel, getConnection, getConnectionFactory, getObservationRegistry, getTransactionalResourceHolder, isChannelTransacted, obtainObservationRegistry, setChannelTransacted, setConnectionFactory

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.amqp.rabbit.listener.MessageListenerContainer

    isConsumerBatchEnabled, lazyLoad

    Methods inherited from interface org.springframework.context.SmartLifecycle

    getPhase, stop
  • Field Details

    • logger

      protected org.springframework.core.log.LogAccessor logger
  • Constructor Details

    • StreamListenerContainer

      public StreamListenerContainer(com.rabbitmq.stream.Environment environment)
      Construct an instance using the provided environment.
      Parameters:
      environment - the environment.
    • StreamListenerContainer

      public StreamListenerContainer(com.rabbitmq.stream.Environment environment, @Nullable com.rabbitmq.stream.Codec codec)
      Construct an instance using the provided environment and codec.
      Parameters:
      environment - the environment.
      codec - the codec used to create reply messages.
  • Method Details

    • setQueueNames

      public void setQueueNames(String... queueNames)
      Mutually exclusive with superStream(String, String).
    • superStream

      public void superStream(String streamName, String name)
      Enable Single Active Consumer on a Super Stream, with one consumer. Mutually exclusive with setQueueNames(String...).
      Parameters:
      streamName - the stream.
      name - the consumer name.
      Since:
      3.0
    • superStream

      public void superStream(String streamName, String name, int consumers)
      Enable Single Active Consumer on a Super Stream with the provided number of consumers. There must be at least that number of partitions in the Super Stream. Mutually exclusive with setQueueNames(String...).
      Parameters:
      streamName - the stream.
      name - the consumer name.
      consumers - the number of consumers.
      Since:
      3.0
    • getStreamConverter

      public StreamMessageConverter getStreamConverter()
      Get a StreamMessageConverter used to convert a Message to a Message.
      Returns:
      the converter.
    • setStreamConverter

      public void setStreamConverter(StreamMessageConverter messageConverter)
      Set a StreamMessageConverter used to convert a Message to a Message.
      Parameters:
      messageConverter - the converter.
    • setConsumerCustomizer

      public void setConsumerCustomizer(ConsumerCustomizer consumerCustomizer)
      Customize the consumer builder before it is built.
      Parameters:
      consumerCustomizer - the customizer.
    • setAutoStartup

      public void setAutoStartup(boolean autoStart)
    • isAutoStartup

      public boolean isAutoStartup()
    • setAdviceChain

      public void setAdviceChain(org.aopalliance.aop.Advice... advices)
      Set an advice chain to apply to the listener.
      Parameters:
      advices - the advice chain.
      Since:
      2.4.5
    • getMessageListener

      @Nullable public Object getMessageListener()
    • setObservationConvention

      public void setObservationConvention(RabbitStreamListenerObservationConvention observationConvention)
      Set a RabbitStreamListenerObservationConvention; used to add additional key/values to observations when using a StreamMessageListener.
      Parameters:
      observationConvention - the convention.
      Since:
      3.0.5
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Specified by:
      afterPropertiesSet in interface org.springframework.amqp.rabbit.listener.MessageListenerContainer
      Overrides:
      afterPropertiesSet in class org.springframework.amqp.rabbit.connection.RabbitAccessor
    • isRunning

      public boolean isRunning()
    • start

      public void start()
    • stop

      public void stop()
    • setupMessageListener

      public void setupMessageListener(org.springframework.amqp.core.MessageListener messageListener)