Class RabbitStreamTemplate

  • All Implemented Interfaces:
    java.lang.AutoCloseable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, RabbitStreamOperations

    public class RabbitStreamTemplate
    extends java.lang.Object
    implements RabbitStreamOperations, org.springframework.beans.factory.BeanNameAware
    Default implementation of RabbitStreamOperations.
    Since:
    2.4
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.springframework.core.log.LogAccessor logger  
    • Constructor Summary

      Constructors 
      Constructor Description
      RabbitStreamTemplate​(com.rabbitmq.stream.Environment environment, java.lang.String streamName)
      Construct an instance with the provided Environment.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      org.springframework.util.concurrent.ListenableFuture<java.lang.Boolean> convertAndSend​(java.lang.Object message)
      Convert to and send a Spring AMQP message.
      org.springframework.util.concurrent.ListenableFuture<java.lang.Boolean> convertAndSend​(java.lang.Object message, org.springframework.amqp.core.MessagePostProcessor mpp)
      Convert to and send a Spring AMQP message.
      com.rabbitmq.stream.MessageBuilder messageBuilder()
      Return the producer's MessageBuilder to create native stream messages.
      org.springframework.amqp.support.converter.MessageConverter messageConverter()
      Return the message converter.
      org.springframework.util.concurrent.ListenableFuture<java.lang.Boolean> send​(com.rabbitmq.stream.Message message)
      Send a native stream message.
      org.springframework.util.concurrent.ListenableFuture<java.lang.Boolean> send​(org.springframework.amqp.core.Message message)
      Send a Spring AMQP message.
      void setBeanName​(java.lang.String name)  
      void setMessageConverter​(org.springframework.amqp.support.converter.MessageConverter messageConverter)
      Set a converter for convertAndSend(Object) operations.
      void setProducerCustomizer​(ProducerCustomizer producerCustomizer)
      Used to customize the ProducerBuilder before the Producer is built.
      void setStreamConverter​(StreamMessageConverter streamConverter)
      Set a converter to convert from Message to Message for send(Message) and convertAndSend(Object) methods.
      StreamMessageConverter streamMessageConverter()
      Return the stream message converter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

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

      • RabbitStreamTemplate

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

      • setBeanName

        public void setBeanName​(java.lang.String name)
        Specified by:
        setBeanName in interface org.springframework.beans.factory.BeanNameAware
      • setMessageConverter

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

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

        public org.springframework.util.concurrent.ListenableFuture<java.lang.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 org.springframework.util.concurrent.ListenableFuture<java.lang.Boolean> convertAndSend​(java.lang.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 org.springframework.util.concurrent.ListenableFuture<java.lang.Boolean> convertAndSend​(java.lang.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.
      • 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 java.lang.AutoCloseable
        Specified by:
        close in interface RabbitStreamOperations