stream-client 全局线程已死于 Spring 启动应用程序关闭
stream-client Global thread has died on Spring Boot application shutdown
我通过使用 Spring Kafka StreamBuilderFactoryBean
配置 Kafka Streams 来创建嵌入在 Spring Boot 应用程序中的 Kafka Streams 应用程序。然后我自动连接 StreamsBuilder
来设置 Kafka Streams 拓扑:
@Bean("streamsBuilder")
public StreamsBuilderFactoryBean streamBuilderFactory() {
Map<String, Object> config = createConfig();
CleanupConfig cleanupConfig = new CleanupConfig(false, false);
KafkaStreamsConfiguration kafkaStreamsConfiguration = new KafkaStreamsConfiguration(config);
return new StreamsBuilderFactoryBean(kafkaStreamsConfiguration, cleanupConfig);
}
和
@Bean("streamTopology")
public KStream<Key, Value> configureTopology(
@Qualifier("streamsBuilder") StreamsBuilder builder) {
// set up and return topology
}
对于使用一个或多个 GlobalKTables 的嵌入式 Kafka Streams 应用程序,在关闭时始终会生成以下错误日志:
stream-client [xxx] Global thread has died. The streams application or client will now close to ERROR.
似乎 Streams 应用程序在应用程序关闭时未被 Spring 正常停止。是否缺少某些配置或关闭挂钩以防止这种情况发生?我的印象是 spring-kafka 会正常关闭。
提前感谢您的帮助!
正如 Mathias Sax 在 Slack 上的回答,这是 Kafka 2.8.0 的一个已知错误:
见https://issues.apache.org/jira/browse/KAFKA-13423 and corresponding Pull Request https://github.com/apache/kafka/pull/11455
我通过使用 Spring Kafka StreamBuilderFactoryBean
配置 Kafka Streams 来创建嵌入在 Spring Boot 应用程序中的 Kafka Streams 应用程序。然后我自动连接 StreamsBuilder
来设置 Kafka Streams 拓扑:
@Bean("streamsBuilder")
public StreamsBuilderFactoryBean streamBuilderFactory() {
Map<String, Object> config = createConfig();
CleanupConfig cleanupConfig = new CleanupConfig(false, false);
KafkaStreamsConfiguration kafkaStreamsConfiguration = new KafkaStreamsConfiguration(config);
return new StreamsBuilderFactoryBean(kafkaStreamsConfiguration, cleanupConfig);
}
和
@Bean("streamTopology")
public KStream<Key, Value> configureTopology(
@Qualifier("streamsBuilder") StreamsBuilder builder) {
// set up and return topology
}
对于使用一个或多个 GlobalKTables 的嵌入式 Kafka Streams 应用程序,在关闭时始终会生成以下错误日志:
stream-client [xxx] Global thread has died. The streams application or client will now close to ERROR.
似乎 Streams 应用程序在应用程序关闭时未被 Spring 正常停止。是否缺少某些配置或关闭挂钩以防止这种情况发生?我的印象是 spring-kafka 会正常关闭。
提前感谢您的帮助!
正如 Mathias Sax 在 Slack 上的回答,这是 Kafka 2.8.0 的一个已知错误:
见https://issues.apache.org/jira/browse/KAFKA-13423 and corresponding Pull Request https://github.com/apache/kafka/pull/11455