Class RabbitStreamTemplate

java.lang.Object
org.springframework.rabbit.stream.producer.RabbitStreamTemplate
All Implemented Interfaces:
AutoCloseable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, RabbitStreamOperations

public class RabbitStreamTemplate extends Object implements RabbitStreamOperations, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanNameAware
Default implementation of RabbitStreamOperations.
Since:
2.4
  • Field Details

    • logger

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

    • RabbitStreamTemplate

      public RabbitStreamTemplate(com.rabbitmq.stream.Environment environment, String streamName)
      Construct an instance with the provided Environment.
      Parameters:
      environment - the environment.
      streamName - the stream name.
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • setBeanName

      public void setBeanName(String name)
      Specified by:
      setBeanName in interface org.springframework.beans.factory.BeanNameAware
    • setSuperStreamRouting

      public void setSuperStreamRouting(Function<com.rabbitmq.stream.Message,String> superStreamRouting)
      Add a routing function, making the stream a super stream.
      Parameters:
      superStreamRouting - the routing function.
      Since:
      3.0
    • setMessageConverter

      public void setMessageConverter(org.springframework.amqp.support.converter.MessageConverter messageConverter)
      Set a converter for convertAndSend(Object) operations.
      Parameters:
      messageConverter - the converter.
    • setStreamConverter

      public void setStreamConverter(StreamMessageConverter streamConverter)
      Set a converter to convert from Message to Message for send(Message) and convertAndSend(Object) methods.
      Parameters:
      streamConverter - the converter.
    • setProducerCustomizer

      public void setProducerCustomizer(ProducerCustomizer producerCustomizer)
      Used to customize the ProducerBuilder before the Producer is built.
      Parameters:
      producerCustomizer - the customizer;
    • setObservationEnabled

      public void setObservationEnabled(boolean observationEnabled)
      Set to true to enable Micrometer observation.
      Parameters:
      observationEnabled - true to enable.
      Since:
      3.0.5
    • messageConverter

      public org.springframework.amqp.support.converter.MessageConverter messageConverter()
      Description copied from interface: RabbitStreamOperations
      Return the message converter.
      Specified by:
      messageConverter in interface RabbitStreamOperations
      Returns:
      the converter.
    • streamMessageConverter

      public StreamMessageConverter streamMessageConverter()
      Description copied from interface: RabbitStreamOperations
      Return the stream message converter.
      Specified by:
      streamMessageConverter in interface RabbitStreamOperations
      Returns:
      the converter;
    • send

      public CompletableFuture<Boolean> send(org.springframework.amqp.core.Message message)
      Description copied from interface: RabbitStreamOperations
      Send a Spring AMQP message.
      Specified by:
      send in interface RabbitStreamOperations
      Parameters:
      message - the message.
      Returns:
      a future to indicate success/failure.
    • convertAndSend

      public CompletableFuture<Boolean> convertAndSend(Object message)
      Description copied from interface: RabbitStreamOperations
      Convert to and send a Spring AMQP message.
      Specified by:
      convertAndSend in interface RabbitStreamOperations
      Parameters:
      message - the payload.
      Returns:
      a future to indicate success/failure.
    • convertAndSend

      public CompletableFuture<Boolean> convertAndSend(Object message, @Nullable org.springframework.amqp.core.MessagePostProcessor mpp)
      Description copied from interface: RabbitStreamOperations
      Convert to and send a Spring AMQP message. If a MessagePostProcessor is provided and returns null, the message is not sent and the future is completed with false.
      Specified by:
      convertAndSend in interface RabbitStreamOperations
      Parameters:
      message - the payload.
      mpp - a message post processor.
      Returns:
      a future to indicate success/failure.
    • send

      public CompletableFuture<Boolean> send(com.rabbitmq.stream.Message message)
      Description copied from interface: RabbitStreamOperations
      Send a native stream message.
      Specified by:
      send in interface RabbitStreamOperations
      Parameters:
      message - the message.
      Returns:
      a future to indicate success/failure.
      See Also:
    • messageBuilder

      public com.rabbitmq.stream.MessageBuilder messageBuilder()
      Description copied from interface: RabbitStreamOperations
      Return the producer's MessageBuilder to create native stream messages.
      Specified by:
      messageBuilder in interface RabbitStreamOperations
      Returns:
      the builder.
      See Also:
    • close

      public void close()

      Close the underlying producer; a new producer will be created on the next operation that requires one.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface RabbitStreamOperations