Spring boot 在ConsumerConfig中添加kafka AutoStart false
如何在property lvl中手动添加kafka property AutoStart false?我的意思是,例如,我可以这样做: @KafkaListener(autoStartUp=“false”) 但我想在消费者财产中,在自己的BeanPostProcessor中进行。我在ConsumerProperties中找不到此属性,例如: Map props=newhashmap()Spring boot 在ConsumerConfig中添加kafka AutoStart false,spring-boot,spring-kafka,Spring Boot,Spring Kafka,如何在property lvl中手动添加kafka property AutoStart false?我的意思是,例如,我可以这样做: @KafkaListener(autoStartUp=“false”) 但我想在消费者财产中,在自己的BeanPostProcessor中进行。我在ConsumerProperties中找不到此属性,例如: Map props=newhashmap() autoStartup与ApacheKafka无关。它是本机Spring容器功能:。因此,即使可以通过您的道具
autoStartup
与ApacheKafka无关。它是本机Spring容器功能:。因此,即使可以通过您的道具
,这听起来也不合理,感觉更像是滥用Apache Kafka配置和Kafka机制无法解析的选项
您需要真正注意的是autoStartup
选项JavaDocs:
/**
* Set to true or false, to override the default setting in the container factory. May
* be a property placeholder or SpEL expression that evaluates to a {@link Boolean} or
* a {@link String}, in which case the {@link Boolean#parseBoolean(String)} is used to
* obtain the value.
* <p>SpEL {@code #{...}} and property place holders {@code ${...}} are supported.
* @return true to auto start, false to not auto start.
* @since 2.2
*/
String autoStartup() default "";
谢谢,这是个好主意,但是如果我没有访问@KafkaListener?这就是为什么我询问有关属性或如何使用其他wayWell实现的原因,否则也可以通过为该
@KafkaListener
提供的ConcurrentKafkaListenerContainerFactory
实现。但是如果你也不能访问它,你就根本不能这么做。您可能需要询问为您开发该库的团队,让他们在@KafkaListener
上访问这些选项。
/**
* Set to true or false, to override the default setting in the container factory. May
* be a property placeholder or SpEL expression that evaluates to a {@link Boolean} or
* a {@link String}, in which case the {@link Boolean#parseBoolean(String)} is used to
* obtain the value.
* <p>SpEL {@code #{...}} and property place holders {@code ${...}} are supported.
* @return true to auto start, false to not auto start.
* @since 2.2
*/
String autoStartup() default "";
@KafkaListener(autoStartUp = "#{props.autoStartUp}")