Class RabbitStreamTemplate
- java.lang.Object
-
- org.springframework.rabbit.stream.producer.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 ofRabbitStreamOperations.- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.core.log.LogAccessorlogger
-
Constructor Summary
Constructors Constructor Description RabbitStreamTemplate(com.rabbitmq.stream.Environment environment, java.lang.String streamName)Construct an instance with the providedEnvironment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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.MessageBuildermessageBuilder()Return the producer'sMessageBuilderto create native stream messages.org.springframework.amqp.support.converter.MessageConvertermessageConverter()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.voidsetBeanName(java.lang.String name)voidsetMessageConverter(org.springframework.amqp.support.converter.MessageConverter messageConverter)Set a converter forconvertAndSend(Object)operations.voidsetProducerCustomizer(ProducerCustomizer producerCustomizer)Used to customize theProducerBuilderbefore theProduceris built.voidsetStreamConverter(StreamMessageConverter streamConverter)Set a converter to convert fromMessagetoMessageforsend(Message)andconvertAndSend(Object)methods.StreamMessageConverterstreamMessageConverter()Return the stream message converter.
-
-
-
Method Detail
-
setBeanName
public void setBeanName(java.lang.String name)
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
setMessageConverter
public void setMessageConverter(org.springframework.amqp.support.converter.MessageConverter messageConverter)
Set a converter forconvertAndSend(Object)operations.- Parameters:
messageConverter- the converter.
-
setStreamConverter
public void setStreamConverter(StreamMessageConverter streamConverter)
Set a converter to convert fromMessagetoMessageforsend(Message)andconvertAndSend(Object)methods.- Parameters:
streamConverter- the converter.
-
setProducerCustomizer
public void setProducerCustomizer(ProducerCustomizer producerCustomizer)
Used to customize theProducerBuilderbefore theProduceris built.- Parameters:
producerCustomizer- the customizer;
-
messageConverter
public org.springframework.amqp.support.converter.MessageConverter messageConverter()
Description copied from interface:RabbitStreamOperationsReturn the message converter.- Specified by:
messageConverterin interfaceRabbitStreamOperations- Returns:
- the converter.
-
streamMessageConverter
public StreamMessageConverter streamMessageConverter()
Description copied from interface:RabbitStreamOperationsReturn the stream message converter.- Specified by:
streamMessageConverterin interfaceRabbitStreamOperations- Returns:
- the converter;
-
send
public org.springframework.util.concurrent.ListenableFuture<java.lang.Boolean> send(org.springframework.amqp.core.Message message)
Description copied from interface:RabbitStreamOperationsSend a Spring AMQP message.- Specified by:
sendin interfaceRabbitStreamOperations- 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:RabbitStreamOperationsConvert to and send a Spring AMQP message.- Specified by:
convertAndSendin interfaceRabbitStreamOperations- 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:RabbitStreamOperationsConvert to and send a Spring AMQP message. If aMessagePostProcessoris provided and returnsnull, the message is not sent and the future is completed withfalse.- Specified by:
convertAndSendin interfaceRabbitStreamOperations- Parameters:
message- the payload.mpp- a message post processor.- Returns:
- a future to indicate success/failure.
-
send
public org.springframework.util.concurrent.ListenableFuture<java.lang.Boolean> send(com.rabbitmq.stream.Message message)
Description copied from interface:RabbitStreamOperationsSend a native stream message.- Specified by:
sendin interfaceRabbitStreamOperations- Parameters:
message- the message.- Returns:
- a future to indicate success/failure.
- See Also:
RabbitStreamOperations.messageBuilder()
-
messageBuilder
public com.rabbitmq.stream.MessageBuilder messageBuilder()
Description copied from interface:RabbitStreamOperationsReturn the producer'sMessageBuilderto create native stream messages.- Specified by:
messageBuilderin interfaceRabbitStreamOperations- Returns:
- the builder.
- See Also:
RabbitStreamOperations.send(com.rabbitmq.stream.Message)
-
close
public void close()
Close the underlying producer; a new producer will be created on the next operation that requires one.
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceRabbitStreamOperations
-
-