Class RabbitStreamTemplate
- java.lang.Object
-
- org.springframework.rabbit.stream.producer.RabbitStreamTemplate
-
- All Implemented Interfaces:
AutoCloseable
,Aware
,BeanNameAware
,RabbitStreamOperations
public class RabbitStreamTemplate extends Object implements RabbitStreamOperations, BeanNameAware
Default implementation ofRabbitStreamOperations
.- Since:
- 2.4
- Author:
- Gary Russell
-
-
Field Summary
Fields Modifier and Type Field Description protected LogAccessor
logger
-
Constructor Summary
Constructors Constructor Description RabbitStreamTemplate(com.rabbitmq.stream.Environment environment, String streamName)
Construct an instance with the providedEnvironment
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
ListenableFuture<Boolean>
convertAndSend(Object message)
Convert to and send a Spring AMQP message.ListenableFuture<Boolean>
convertAndSend(Object message, MessagePostProcessor mpp)
Convert to and send a Spring AMQP message.com.rabbitmq.stream.MessageBuilder
messageBuilder()
Return the producer'sMessageBuilder
to create native stream messages.MessageConverter
messageConverter()
Return the message converter.ListenableFuture<Boolean>
send(com.rabbitmq.stream.Message message)
Send a native stream message.ListenableFuture<Boolean>
send(Message message)
Send a Spring AMQP message.void
setBeanName(String name)
void
setMessageConverter(MessageConverter messageConverter)
Set a converter forconvertAndSend(Object)
operations.void
setProducerCustomizer(ProducerCustomizer producerCustomizer)
Used to customize theProducerBuilder
before theProducer
is built.void
setStreamConverter(StreamMessageConverter streamConverter)
Set a converter to convert fromMessage
toMessage
forsend(Message)
andconvertAndSend(Object)
methods.StreamMessageConverter
streamMessageConverter()
Return the stream message converter.
-
-
-
Field Detail
-
logger
protected final LogAccessor logger
-
-
Constructor Detail
-
RabbitStreamTemplate
public RabbitStreamTemplate(com.rabbitmq.stream.Environment environment, String streamName)
Construct an instance with the providedEnvironment
.- Parameters:
environment
- the environment.streamName
- the stream name.
-
-
Method Detail
-
setBeanName
public void setBeanName(String name)
- Specified by:
setBeanName
in interfaceBeanNameAware
-
setMessageConverter
public void setMessageConverter(MessageConverter messageConverter)
Set a converter forconvertAndSend(Object)
operations.- Parameters:
messageConverter
- the converter.
-
setStreamConverter
public void setStreamConverter(StreamMessageConverter streamConverter)
Set a converter to convert fromMessage
toMessage
forsend(Message)
andconvertAndSend(Object)
methods.- Parameters:
streamConverter
- the converter.
-
setProducerCustomizer
public void setProducerCustomizer(ProducerCustomizer producerCustomizer)
Used to customize theProducerBuilder
before theProducer
is built.- Parameters:
producerCustomizer
- the customizer;
-
messageConverter
public MessageConverter messageConverter()
Description copied from interface:RabbitStreamOperations
Return the message converter.- Specified by:
messageConverter
in interfaceRabbitStreamOperations
- Returns:
- the converter.
-
streamMessageConverter
public StreamMessageConverter streamMessageConverter()
Description copied from interface:RabbitStreamOperations
Return the stream message converter.- Specified by:
streamMessageConverter
in interfaceRabbitStreamOperations
- Returns:
- the converter;
-
send
public ListenableFuture<Boolean> send(Message message)
Description copied from interface:RabbitStreamOperations
Send a Spring AMQP message.- Specified by:
send
in interfaceRabbitStreamOperations
- Parameters:
message
- the message.- Returns:
- a future to indicate success/failure.
-
convertAndSend
public ListenableFuture<Boolean> convertAndSend(Object message)
Description copied from interface:RabbitStreamOperations
Convert to and send a Spring AMQP message.- Specified by:
convertAndSend
in interfaceRabbitStreamOperations
- Parameters:
message
- the payload.- Returns:
- a future to indicate success/failure.
-
convertAndSend
public ListenableFuture<Boolean> convertAndSend(Object message, @Nullable MessagePostProcessor mpp)
Description copied from interface:RabbitStreamOperations
Convert to and send a Spring AMQP message. If aMessagePostProcessor
is provided and returnsnull
, the message is not sent and the future is completed withfalse
.- Specified by:
convertAndSend
in interfaceRabbitStreamOperations
- Parameters:
message
- the payload.mpp
- a message post processor.- Returns:
- a future to indicate success/failure.
-
send
public ListenableFuture<Boolean> send(com.rabbitmq.stream.Message message)
Description copied from interface:RabbitStreamOperations
Send a native stream message.- Specified by:
send
in 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:RabbitStreamOperations
Return the producer'sMessageBuilder
to create native stream messages.- Specified by:
messageBuilder
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceRabbitStreamOperations
-
-