Spring boot 在修改主题时重置Spring Boot Kafka流应用程序
我使用SpringKafka在SpringBoot应用程序中使用StreamsBuilderFactoryBean运行kafka流。我通过删除并重新创建一些主题中的分区,将它们的数量从100更改为20,但现在运行应用程序时,出现以下错误:Spring boot 在修改主题时重置Spring Boot Kafka流应用程序,spring-boot,apache-kafka,apache-kafka-streams,spring-kafka,Spring Boot,Apache Kafka,Apache Kafka Streams,Spring Kafka,我使用SpringKafka在SpringBoot应用程序中使用StreamsBuilderFactoryBean运行kafka流。我通过删除并重新创建一些主题中的分区,将它们的数量从100更改为20,但现在运行应用程序时,出现以下错误: Existing internal topic MyAppId-KSTREAM-AGGREGATE-STATE-STORE-0000000092-changelog has invalid partitions: expected: 20; actual: 1
Existing internal topic MyAppId-KSTREAM-AGGREGATE-STATE-STORE-0000000092-changelog has invalid partitions: expected: 20; actual: 100. Use 'kafka.tools.StreamsResetter' tool to clean up invalid topics before processing.
我无法访问类kafka.tools.StreamsResetter并尝试调用StreamsBuilderFactoryBean.getKafkaStreams.cleanup,但它给出了NullPointerException。如何进行上述清理?相关文档位于 步骤1:本地清理 对于使用StreamsBuilderFactoryBean的Spring引导,第一步可以通过简单地向构造函数添加CleanerConfig来完成: //以前 新的StreamsBuilderFactoryBeannew Kafkastreams配置配置; //之后 新建StreamsBuilderFactoryBeannew KafkastreamsConfiguration配置,新建CleanupConfigtrue,true; 这允许在启动前和停止后调用KafkaStreams.cleanUp方法 步骤2:全局清理 对于第二步,当应用程序的所有实例都停止时,只需使用文档中所述的工具: 在卡夫卡目录中 bin/kafka-streams-application-reset.sh-应用程序id MyAppId-引导服务器1.2.3.4:9092-输入主题x-中间主题第一、第二、第三-zookeeper 1.2.3.4:2181 它的作用是: 对于任何指定的输入主题:为consumer group application.id的所有分区将应用程序的已提交使用者偏移量重置为主题的开头 对于任何指定的中间主题:跳到主题的末尾,即将应用程序提交的所有分区的使用者偏移量设置为每个分区的使用者组application.id的logSize 对于任何内部主题:删除内部主题这也将删除相应的提交偏移量 如文件所述: