Package org.springframework.kafka.config
Class KafkaListenerEndpointRegistrar
- java.lang.Object
-
- org.springframework.kafka.config.KafkaListenerEndpointRegistrar
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.InitializingBean
public class KafkaListenerEndpointRegistrar extends java.lang.Object implements org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean
Helper bean for registeringKafkaListenerEndpoint
with aKafkaListenerEndpointRegistry
.- Author:
- Stephane Nicoll, Juergen Hoeller, Artem Bilan, Gary Russell, Filip Halemba
- See Also:
KafkaListenerConfigurer
-
-
Constructor Summary
Constructors Constructor Description KafkaListenerEndpointRegistrar()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
java.util.List<org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver>
getCustomMethodArgumentResolvers()
Return the list ofHandlerMethodArgumentResolver
.KafkaListenerEndpointRegistry
getEndpointRegistry()
Return theKafkaListenerEndpointRegistry
instance for this registrar, may benull
.org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory
getMessageHandlerMethodFactory()
Return the customMessageHandlerMethodFactory
to use, if any.org.springframework.validation.Validator
getValidator()
Get the validator, if supplied.protected void
registerAllEndpoints()
void
registerEndpoint(KafkaListenerEndpoint endpoint)
Register a newKafkaListenerEndpoint
using the defaultKafkaListenerContainerFactory
to create the underlying container.void
registerEndpoint(KafkaListenerEndpoint endpoint, KafkaListenerContainerFactory<?> factory)
Register a newKafkaListenerEndpoint
alongside theKafkaListenerContainerFactory
to use to create the underlying container.void
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
ABeanFactory
only needs to be available in conjunction withsetContainerFactoryBeanName(java.lang.String)
.void
setContainerFactory(KafkaListenerContainerFactory<?> containerFactory)
Set theKafkaListenerContainerFactory
to use in case aKafkaListenerEndpoint
is registered with anull
container factory.void
setContainerFactoryBeanName(java.lang.String containerFactoryBeanName)
Set the bean name of theKafkaListenerContainerFactory
to use in case aKafkaListenerEndpoint
is registered with anull
container factory.void
setCustomMethodArgumentResolvers(org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver... methodArgumentResolvers)
Add custom methods arguments resolvers toKafkaListenerAnnotationBeanPostProcessor
Default empty list.void
setEndpointRegistry(KafkaListenerEndpointRegistry endpointRegistry)
Set theKafkaListenerEndpointRegistry
instance to use.void
setMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory kafkaHandlerMethodFactory)
Set theMessageHandlerMethodFactory
to use to configure the message listener responsible to serve an endpoint detected by this processor.void
setValidator(org.springframework.validation.Validator validator)
Set the validator to use if the default message handler factory is used.
-
-
-
Method Detail
-
setEndpointRegistry
public void setEndpointRegistry(KafkaListenerEndpointRegistry endpointRegistry)
Set theKafkaListenerEndpointRegistry
instance to use.- Parameters:
endpointRegistry
- theKafkaListenerEndpointRegistry
instance to use.
-
getEndpointRegistry
@Nullable public KafkaListenerEndpointRegistry getEndpointRegistry()
Return theKafkaListenerEndpointRegistry
instance for this registrar, may benull
.- Returns:
- the
KafkaListenerEndpointRegistry
instance for this registrar, may benull
.
-
getCustomMethodArgumentResolvers
public java.util.List<org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver> getCustomMethodArgumentResolvers()
Return the list ofHandlerMethodArgumentResolver
.- Returns:
- the list of
HandlerMethodArgumentResolver
. - Since:
- 2.4.2
-
setCustomMethodArgumentResolvers
public void setCustomMethodArgumentResolvers(org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver... methodArgumentResolvers)
Add custom methods arguments resolvers toKafkaListenerAnnotationBeanPostProcessor
Default empty list.- Parameters:
methodArgumentResolvers
- the methodArgumentResolvers to assign.- Since:
- 2.4.2
-
setMessageHandlerMethodFactory
public void setMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory kafkaHandlerMethodFactory)
Set theMessageHandlerMethodFactory
to use to configure the message listener responsible to serve an endpoint detected by this processor.By default,
DefaultMessageHandlerMethodFactory
is used and it can be configured further to support additional method arguments or to customize conversion and validation support. SeeDefaultMessageHandlerMethodFactory
javadoc for more details.- Parameters:
kafkaHandlerMethodFactory
- theMessageHandlerMethodFactory
instance.
-
getMessageHandlerMethodFactory
@Nullable public org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory getMessageHandlerMethodFactory()
Return the customMessageHandlerMethodFactory
to use, if any.- Returns:
- the custom
MessageHandlerMethodFactory
to use, if any.
-
setContainerFactory
public void setContainerFactory(KafkaListenerContainerFactory<?> containerFactory)
Set theKafkaListenerContainerFactory
to use in case aKafkaListenerEndpoint
is registered with anull
container factory.Alternatively, the bean name of the
KafkaListenerContainerFactory
to use can be specified for a lazy lookup, seesetContainerFactoryBeanName(java.lang.String)
.- Parameters:
containerFactory
- theKafkaListenerContainerFactory
instance.
-
setContainerFactoryBeanName
public void setContainerFactoryBeanName(java.lang.String containerFactoryBeanName)
Set the bean name of theKafkaListenerContainerFactory
to use in case aKafkaListenerEndpoint
is registered with anull
container factory. Alternatively, the container factory instance can be registered directly: seesetContainerFactory(KafkaListenerContainerFactory)
.- Parameters:
containerFactoryBeanName
- theKafkaListenerContainerFactory
bean name.- See Also:
setBeanFactory(org.springframework.beans.factory.BeanFactory)
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
ABeanFactory
only needs to be available in conjunction withsetContainerFactoryBeanName(java.lang.String)
.- Specified by:
setBeanFactory
in interfaceorg.springframework.beans.factory.BeanFactoryAware
- Parameters:
beanFactory
- theBeanFactory
instance.
-
getValidator
@Nullable public org.springframework.validation.Validator getValidator()
Get the validator, if supplied.- Returns:
- the validator.
- Since:
- 2.2
-
setValidator
public void setValidator(org.springframework.validation.Validator validator)
Set the validator to use if the default message handler factory is used.- Parameters:
validator
- the validator.- Since:
- 2.2
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
registerAllEndpoints
protected void registerAllEndpoints()
-
registerEndpoint
public void registerEndpoint(KafkaListenerEndpoint endpoint, @Nullable KafkaListenerContainerFactory<?> factory)
Register a newKafkaListenerEndpoint
alongside theKafkaListenerContainerFactory
to use to create the underlying container.The
factory
may benull
if the default factory has to be used for that endpoint.- Parameters:
endpoint
- theKafkaListenerEndpoint
instance to register.factory
- theKafkaListenerContainerFactory
to use.
-
registerEndpoint
public void registerEndpoint(KafkaListenerEndpoint endpoint)
Register a newKafkaListenerEndpoint
using the defaultKafkaListenerContainerFactory
to create the underlying container.- Parameters:
endpoint
- theKafkaListenerEndpoint
instance to register.- See Also:
setContainerFactory(KafkaListenerContainerFactory)
,registerEndpoint(KafkaListenerEndpoint, KafkaListenerContainerFactory)
-
-