简体   繁体   English

Spring Kafka为主题配置分区数

[英]Spring Kafka configure number of partitions for topic

Is it possible in Spring Kafka configure the number of partitions for the specific topic in order to be able to effectively use org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory.setConcurrency(Integer) method to parallel consumers on this topic in order to speed up message consumptions and processing? 在Spring Kafka中是否可以为特定主题配置分区数,以便能够有效地使用org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory.setConcurrency(Integer)方法在该主题上并行使用消费者,从而加快消息传递消费和加工? If so, could you please show the example of how it can be done. 如果是这样,请您举例说明如何完成此操作。

See Configuring Topics . 请参阅配置主题

@Bean
public NewTopic topic1() {
    return new NewTopic("foo", 10, (short) 2);
}

Will create a topic foo with 10 partitions and a replication factor of 2 (if there is a KafkaAdmin bean in the application context). 将创建一个具有10个分区和2的复制因子的主题foo (如果应用程序上下文中有一个KafkaAdmin bean)。

Spring boot auto-configures a KafkaAdmin @Bean . 春季启动会自动配置KafkaAdmin @Bean

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 spring cloud stream kafka binder 以编程方式将 kafka 主题(多个分区)偏移量重置为任意数字 - spring cloud stream kafka binder resetting a kafka topic(multiple partitions) offset to an arbitrary number programatically Spring Kafka和主题消费者数量 - Spring Kafka and number of topic consumers 如何在使用 Spring 创建期间配置 kafka 主题保留策略? - How to configure kafka topic retention policy during creation with Spring? 使用Spring Kafka进行Kafka主题排序 - Kafka Topic ordering with Spring Kafka 用 spring 管理 Kafka Topic - Managing Kafka Topic with spring 如何配置频率(一天一次)以在 Spring Boot 中读取来自 Kafka 主题的消息 - How to configure frequency (Once in a day) to read message from Kafka topic in Spring Boot 如何在 Spring Cloud Stream 中配置函数的绑定以将其输入绑定到 Web 端点并将其输出绑定到 Kafka 主题 - How to configure the bindings of a function in Spring Cloud Stream to bind its input to a web endpoint and its output to a Kafka topic 嵌入式 Kafka 以错误的分区数开始 - Embedded Kafka starting with wrong number of partitions 使用spring @Bean创建kafka主题? - creating kafka topic using spring @Bean? Spring kafka 单元测试侦听器未订阅主题 - Spring kafka unit test listener not subscribing to topic
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM