Class StreamListenerContainer
java.lang.Object
org.springframework.amqp.rabbit.connection.RabbitAccessor
org.springframework.amqp.rabbit.listener.ObservableListenerContainer
org.springframework.rabbit.stream.listener.StreamListenerContainer
- All Implemented Interfaces:
MessageListenerContainer,Aware,BeanNameAware,DisposableBean,InitializingBean,ApplicationContextAware,Lifecycle,Phased,SmartLifecycle
A listener container for RabbitMQ Streams.
- Since:
- 2.4
- Author:
- Gary Russell
-
Field Summary
FieldsFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionStreamListenerContainer(com.rabbitmq.stream.Environment environment) Construct an instance using the provided environment.StreamListenerContainer(com.rabbitmq.stream.Environment environment, com.rabbitmq.stream.Codec codec) Construct an instance using the provided environment and codec. -
Method Summary
Modifier and TypeMethodDescriptionvoidGet the message listener.booleanbooleanvoidsetAdviceChain(Advice... advices) Set an advice chain to apply to the listener.voidsetAutoStartup(boolean autoStart) Set auto startup.voidsetConsumerCustomizer(ConsumerCustomizer consumerCustomizer) Customize the consumer builder before it is built.voidsetObservationConvention(RabbitStreamListenerObservationConvention observationConvention) Set a RabbitStreamListenerObservationConvention; used to add additional key/values to observations when using aStreamMessageListener.voidsetQueueNames(String... queueNames) Set the queue names.voidsetStreamConverter(StreamMessageConverter messageConverter) voidsetupMessageListener(MessageListener messageListener) Setup the message listener to use.voidstart()voidstop()voidsuperStream(String streamName, String name) Enable Single Active Consumer on a Super Stream, with one consumer.voidsuperStream(String streamName, String name, int consumers) Enable Single Active Consumer on a Super Stream with the provided number of consumers.Methods inherited from class org.springframework.amqp.rabbit.listener.ObservableListenerContainer
checkMicrometer, checkObservation, destroy, getApplicationContext, getBeanName, getListenerId, getMicrometerHolder, setApplicationContext, setBeanName, setListenerId, setMicrometerEnabled, setMicrometerTags, setObservationEnabledMethods inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor
convertRabbitAccessException, createConnection, getChannel, getConnection, getConnectionFactory, getObservationRegistry, getTransactionalResourceHolder, isChannelTransacted, obtainObservationRegistry, setChannelTransacted, setConnectionFactoryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.amqp.rabbit.listener.MessageListenerContainer
isConsumerBatchEnabled, lazyLoadMethods inherited from interface org.springframework.context.SmartLifecycle
getPhase, stop
-
Field Details
-
logger
-
-
Constructor Details
-
StreamListenerContainer
public StreamListenerContainer(com.rabbitmq.stream.Environment environment) Construct an instance using the provided environment.- Parameters:
environment- the environment.
-
StreamListenerContainer
public StreamListenerContainer(com.rabbitmq.stream.Environment environment, @Nullable com.rabbitmq.stream.Codec codec) Construct an instance using the provided environment and codec.- Parameters:
environment- the environment.codec- the codec used to create reply messages.
-
-
Method Details
-
setQueueNames
Set the queue names. Mutually exclusive withsuperStream(String, String).- Parameters:
queueNames- the queue names.
-
superStream
Enable Single Active Consumer on a Super Stream, with one consumer. Mutually exclusive withsetQueueNames(String...).- Parameters:
streamName- the stream.name- the consumer name.- Since:
- 3.0
-
superStream
Enable Single Active Consumer on a Super Stream with the provided number of consumers. There must be at least that number of partitions in the Super Stream. Mutually exclusive withsetQueueNames(String...).- Parameters:
streamName- the stream.name- the consumer name.consumers- the number of consumers.- Since:
- 3.0
-
getStreamConverter
- Returns:
- the converter.
-
setStreamConverter
- Parameters:
messageConverter- the converter.
-
setConsumerCustomizer
Customize the consumer builder before it is built.- Parameters:
consumerCustomizer- the customizer.
-
setAutoStartup
public void setAutoStartup(boolean autoStart) Description copied from interface:MessageListenerContainerSet auto startup.- Parameters:
autoStart- true to auto start.
-
isAutoStartup
public boolean isAutoStartup() -
setAdviceChain
Set an advice chain to apply to the listener.- Parameters:
advices- the advice chain.- Since:
- 2.4.5
-
getMessageListener
Description copied from interface:MessageListenerContainerGet the message listener.- Returns:
- The message listener object.
-
setObservationConvention
public void setObservationConvention(RabbitStreamListenerObservationConvention observationConvention) Set a RabbitStreamListenerObservationConvention; used to add additional key/values to observations when using aStreamMessageListener.- Parameters:
observationConvention- the convention.- Since:
- 3.0.5
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean- Specified by:
afterPropertiesSetin interfaceMessageListenerContainer- Overrides:
afterPropertiesSetin classRabbitAccessor
-
isRunning
public boolean isRunning() -
start
public void start() -
stop
public void stop() -
setupMessageListener
Description copied from interface:MessageListenerContainerSetup the message listener to use. Throws anIllegalArgumentExceptionif that message listener type is not supported.- Parameters:
messageListener- theobjectto wrapped to theMessageListener.
-