Package org.springframework.kafka.config
Class ConcurrentKafkaListenerContainerFactory<K,V>
java.lang.Object
org.springframework.kafka.config.AbstractKafkaListenerContainerFactory<ConcurrentMessageListenerContainer<K,V>,K,V>
org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory<K,V>
- Type Parameters:
K
- the key type.V
- the value type.
- All Implemented Interfaces:
Aware
,ApplicationContextAware
,ApplicationEventPublisherAware
,KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<K,
V>>
public class ConcurrentKafkaListenerContainerFactory<K,V>
extends AbstractKafkaListenerContainerFactory<ConcurrentMessageListenerContainer<K,V>,K,V>
A
KafkaListenerContainerFactory
implementation to build a
ConcurrentMessageListenerContainer
.
This should be the default for most users and a good transition paths for those that
are used to building such container definitions manually.
This factory is primarily for building containers for KafkaListener
annotated
methods but can also be used to create any container.
Only containers for KafkaListener
annotated methods are added to the
KafkaListenerEndpointRegistry
.
- Author:
- Stephane Nicoll, Gary Russell, Artem Bilan, Murali Reddy
-
Field Summary
Fields inherited from class org.springframework.kafka.config.AbstractKafkaListenerContainerFactory
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ConcurrentMessageListenerContainer<K,
V> createContainerInstance
(KafkaListenerEndpoint endpoint) Create an empty container instance.protected void
initializeContainer
(ConcurrentMessageListenerContainer<K, V> instance, KafkaListenerEndpoint endpoint) Further initialize the specified container.void
setConcurrency
(Integer concurrency) Specify the container concurrency.Methods inherited from class org.springframework.kafka.config.AbstractKafkaListenerContainerFactory
createContainer, createContainer, createContainer, createContainer, createListenerContainer, customizeContainer, getConsumerFactory, getContainerProperties, isBatchListener, setAckDiscarded, setAfterRollbackProcessor, setApplicationContext, setApplicationEventPublisher, setAutoStartup, setBatchInterceptor, setBatchListener, setBatchMessageConverter, setBatchToRecordAdapter, setChangeConsumerThreadName, setCommonErrorHandler, setConsumerFactory, setContainerCustomizer, setCorrelationHeaderName, setMissingTopicsFatal, setPhase, setRecordFilterStrategy, setRecordInterceptor, setRecordMessageConverter, setReplyHeadersConfigurer, setReplyTemplate, setThreadNameSupplier
-
Constructor Details
-
ConcurrentKafkaListenerContainerFactory
public ConcurrentKafkaListenerContainerFactory()
-
-
Method Details
-
setConcurrency
Specify the container concurrency.- Parameters:
concurrency
- the number of consumers to create.- See Also:
-
createContainerInstance
protected ConcurrentMessageListenerContainer<K,V> createContainerInstance(KafkaListenerEndpoint endpoint) Description copied from class:AbstractKafkaListenerContainerFactory
Create an empty container instance.- Specified by:
createContainerInstance
in classAbstractKafkaListenerContainerFactory<ConcurrentMessageListenerContainer<K,
V>, K, V> - Parameters:
endpoint
- the endpoint.- Returns:
- the new container instance.
-
initializeContainer
protected void initializeContainer(ConcurrentMessageListenerContainer<K, V> instance, KafkaListenerEndpoint endpoint) Description copied from class:AbstractKafkaListenerContainerFactory
Further initialize the specified container.Subclasses can inherit from this method to apply extra configuration if necessary.
- Overrides:
initializeContainer
in classAbstractKafkaListenerContainerFactory<ConcurrentMessageListenerContainer<K,
V>, K, V> - Parameters:
instance
- the container instance to configure.endpoint
- the endpoint.
-