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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRabbitStreamTemplate(com.rabbitmq.stream.Environment environment, String streamName) Construct an instance with the providedEnvironment. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()convertAndSend(Object message) Convert to and send a Spring AMQP message.convertAndSend(Object message, org.springframework.amqp.core.MessagePostProcessor mpp) Convert to and send a Spring AMQP message.com.rabbitmq.stream.MessageBuilderReturn the producer'sMessageBuilderto create native stream messages.org.springframework.amqp.support.converter.MessageConverterReturn the message converter.send(com.rabbitmq.stream.Message message) Send a native stream message.send(org.springframework.amqp.core.Message message) Send a Spring AMQP message.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetBeanName(String name) voidsetMessageConverter(org.springframework.amqp.support.converter.MessageConverter messageConverter) Set a converter forconvertAndSend(Object)operations.voidsetObservationEnabled(boolean observationEnabled) Set to true to enable Micrometer observation.voidsetProducerCustomizer(ProducerCustomizer producerCustomizer) Used to customize theProducerBuilderbefore theProduceris built.voidsetStreamConverter(StreamMessageConverter streamConverter) Set a converter to convert fromMessagetoMessageforsend(Message)andconvertAndSend(Object)methods.voidsetSuperStreamRouting(Function<com.rabbitmq.stream.Message, String> superStreamRouting) Add a routing function, making the stream a super stream.Return the stream message converter.
-
Field Details
-
logger
protected final org.springframework.core.log.LogAccessor logger
-
-
Constructor Details
-
RabbitStreamTemplate
Construct an instance with the providedEnvironment.- 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:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
setBeanName
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
setSuperStreamRouting
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 forconvertAndSend(Object)operations.- Parameters:
messageConverter- the converter.
-
setStreamConverter
Set a converter to convert fromMessagetoMessageforsend(Message)andconvertAndSend(Object)methods.- Parameters:
streamConverter- the converter.
-
setProducerCustomizer
Used to customize theProducerBuilderbefore theProduceris 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:RabbitStreamOperationsReturn the message converter.- Specified by:
messageConverterin interfaceRabbitStreamOperations- Returns:
- the converter.
-
streamMessageConverter
Description copied from interface:RabbitStreamOperationsReturn the stream message converter.- Specified by:
streamMessageConverterin interfaceRabbitStreamOperations- Returns:
- the converter;
-
send
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
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 CompletableFuture<Boolean> convertAndSend(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
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:
-
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:
-
close
public void close()Close the underlying producer; a new producer will be created on the next operation that requires one.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceRabbitStreamOperations
-