Search code examples
spring-bootapache-kafkaapache-kafka-streamsspring-kafka

stream-client Global thread has died on Spring Boot application shutdown


I create Kafka Streams applications embedded in a Spring Boot application by using the Spring Kafka StreamBuilderFactoryBean to configure Kafka Streams. I then autowire a StreamsBuilder to set up a Kafka Streams topology:

    @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);
    }

and

    @Bean("streamTopology")
    public KStream<Key, Value> configureTopology(
        @Qualifier("streamsBuilder") StreamsBuilder builder) {
        // set up and return topology
    }

For applications with an embedded Kafka Streams App that use one or more GlobalKTables the following ERROR logs are consistently produced on shutdown:

stream-client [xxx] Global thread has died. The streams application or client will now close to ERROR.

It seems like the Streams App is not stopped gracefully by Spring on application shutdown. Is some configuration or shutdown hook missing to prevent this from happening? I was under the impression that spring-kafka would handle graceful shutdown.

Thank you in advance for your help!


Solution

  • As answered by Mathias Sax on Slack, this is a known bug for Kafka 2.8.0:

    See https://issues.apache.org/jira/browse/KAFKA-13423 and corresponding Pull Request https://github.com/apache/kafka/pull/11455