英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论