春季Kafka集成属性,用于使用application.yml/properties的批处理监听器:

huangapple go评论66阅读模式
英文:

Spring kafka integration properties for batch listener using application.yml/properties

问题

我正在尝试在Spring Boot应用中使用Kafka消费者批处理。我可以看到一些示例,其中我们有一个Kafka配置类,在该类中配置了KafkaListenerContainerFactory,并且启用了

ConcurrentKafkaListenerContainerFactory.setBatchListener(true);

我只是在想是否可以在没有工厂类的情况下实现这一点,也就是通过在application.yml中使用Spring Kafka集成属性来实现。之前,我曾经定义过一个工厂类,并且将其替换为了通过application.yml实现的Spring Kafka集成属性,以获得更简洁的代码。我正在尝试理解后一种方法是否存在限制,并且是否更倾向于使用配置类,因为我无法通过application.yml中的Spring Kafka集成属性实现批处理。我参考了这个文档以查看可用的选项:https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html。

英文:

I am trying to use kafka consumer batching in spring boot app. I could see examples, where we have a kafka config class in which, KafkaListenerContainerFactory is configured and

ConcurrentKafkaListenerContainerFactory.setBatchListener(true);

is enabled. i am just wondering if this can be achieved without a factory class, i.e by using spring kafka integration properties in application.yml. Earlier i had defined a factory and replaced it with spring kafa integration properties via application.yml for concise code. I am trying to understand if the latter has limitations and usage of a config class is preferable, as i am unable to achieve batching using spring kafa integration properties via application.yml. https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html I referred this doc to see available options.

答案1

得分: 3

spring.kafka.listener.type=batch(与默认值single相对)。

Spring Boot文档可能需要一些改进。

英文:

spring.kafka.listener.type=batch (Vs. single - the default).

The Boot documentation could use some improvement.

huangapple
  • 本文由 发表于 2020年10月20日 22:00:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/64446770.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定