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

kafka streams stop working after upgrade to spring-kafka:2.5.3.RELEASE


I am trying to upgrade my Spring-boot application to version 2.5.0

Once i do the upgrade:

plugins {
    id 'org.springframework.boot' version '2.5.0'
}

I get an error saying

Failed to introspect Class [org.springframework.boot.actuate.autoconfigure.metrics.KafkaMetricsAutoConfiguration$KafkaStreamsMetricsConfiguration]

Checking this class i find that it is indeed broken as "addListener" in the code below cannot be resolved

static class KafkaStreamsMetricsConfiguration {

    @Bean
    StreamsBuilderFactoryBeanCustomizer kafkaStreamsMetrics(MeterRegistry meterRegistry) {
        return (factoryBean) -> factoryBean.addListener(new KafkaStreamsMicrometerListener(meterRegistry));
    }

}  

The code above is coming from spring-boot-actuator-autoconfigure:2.5.0 jar.

This issue is solved if update my spring-kafka dependency to any version above 2.5.2.RELEASE

for example:

implementation 'org.springframework.kafka:spring-kafka:2.5.3.RELEASE'

"addListener" is now taken from StreamsBuilderFactoryBean under the spring-kafka-2.5.3.release.jar

The real issue is that for some reason this change makes the Kafka stream bean not to run, and no consuming is being done. It seems to somehow break Spring activation of kafka-streams. There is no error of any kind or no indication that something went wrong. It feels disabled.

Some additional information:

i'm using

implementation 'org.apache.kafka:kafka-streams:2.5.0'
implementation 'org.apache.kafka:kafka-clients:2.5.0'

changing their versions doesn't seem to have any effect.

Assuming nothing else changed (application classes and Kafka configuration) - what might be the cause?


Solution

  • You should not specify versions; let Boot's dependency management manage the versions. The current Boot 2.5 version is 2.5.7; it requires spring-kafka 2.7.9 - see the project page for the dependency matrix.

    https://spring.io/projects/spring-kafka

    enter image description here