Class StreamListenerContainer

All Implemented Interfaces:
MessageListenerContainer, Aware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, Lifecycle, Phased, SmartLifecycle

public class StreamListenerContainer extends ObservableListenerContainer
A listener container for RabbitMQ Streams.
Since:
2.4
Author:
Gary Russell, Christian Tzolov
  • Field Details

  • 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)
      Set the queue names. Mutually exclusive with superStream(String, String).
      Parameters:
      queueNames - the queue names.
    • 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)
      Description copied from interface: MessageListenerContainer
      Set auto startup.
      Parameters:
      autoStart - true to auto start.
    • isAutoStartup

      public boolean isAutoStartup()
    • setAdviceChain

      public void setAdviceChain(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()
      Description copied from interface: MessageListenerContainer
      Get the message listener.
      Returns:
      The message listener object.
    • 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 InitializingBean
      Specified by:
      afterPropertiesSet in interface MessageListenerContainer
      Overrides:
      afterPropertiesSet in class RabbitAccessor
    • isRunning

      public boolean isRunning()
    • start

      public void start()
    • stop

      public void stop()
    • setupMessageListener

      public void setupMessageListener(MessageListener messageListener)
      Description copied from interface: MessageListenerContainer
      Setup the message listener to use. Throws an IllegalArgumentException if that message listener type is not supported.
      Parameters:
      messageListener - the object to wrapped to the MessageListener.