[英]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.