This version is still in development and is not considered stable yet. For the latest stable version, please use Spring for Apache Kafka 3.3.6!spring-doc.cn

What’s new?

What’s New in 4.0 Since 3.3

This section covers the changes made from version 3.3 to version 4.0. For changes in earlier versions, see Change History.spring-doc.cn

Apache Kafka 4.0 Client Upgrade

Spring for Apache Kafka has been upgraded to use Apache Kafka client version 4.0.0. This upgrade brings several important changes:spring-doc.cn

  • All ZooKeeper-based functionality has been removed as Kafka 4.0 fully transitions to KRaft modespring-doc.cn

  • The ZooKeeper dependency has been removed from the projectspring-doc.cn

  • The embedded Kafka test framework now exclusively uses KRaft modespring-doc.cn

  • The EmbeddedKafkaZKBroker class has been removed, and all functionality is now handled by EmbeddedKafkaKraftBrokerspring-doc.cn

Embedded Kafka Test Framework Changes

The test infrastructure has been significantly updated:spring-doc.cn

  • The EmbeddedKafkaRule JUnit 4 rule has been removedspring-doc.cn

  • The @EmbeddedKafka annotation has been simplified with the removal of ZooKeeper-related properties:spring-doc.cn

  • The kraft property has been removed as KRaft mode is now the only optionspring-doc.cn

  • ZooKeeper-specific properties like zookeeperPort, zkConnectionTimeout, and zkSessionTimeout have been removedspring-doc.cn

  • KafkaClusterTestKit imports now use new packages for KRaft modespring-doc.cn

  • Some tests have been updated to address limitations with static port assignments in KRaft modespring-doc.cn

  • Adjustments have been made to replication factors in tests to accommodate KRaft requirementsspring-doc.cn

ConsumerRecords Constructor Changes

The ConsumerRecords constructor now requires an additional Map parameter, which has been addressed throughout the framework. Applications that directly use this constructor will need to update their code.spring-doc.cn

Producer Interface Updates

New methods from the Kafka Producer interface have been implemented:spring-doc.cn

Removed Deprecated Functionality

Several deprecated items have been removed:spring-doc.cn

  • The deprecated partitioner classes have been removed from runtime hintsspring-doc.cn

  • The deprecated sendOffsetsToTransaction method that used String consumerGroupId has been removedspring-doc.cn

Kafka Streams API Changes

  • KafkaStreamBrancher has been updated to use the new split() and branch() methods instead of the deprecated branch() methodspring-doc.cn

  • The DeserializationExceptionHandler has been updated to use the new ErrorHandlerContextspring-doc.cn

Internal API Updates related to Apache Kafka 4.0.0

  • The BrokerAddress class now uses org.apache.kafka.server.network.BrokerEndPoint instead of the deprecated kafka.cluster.BrokerEndPointspring-doc.cn

  • The GlobalEmbeddedKafkaTestExecutionListener has been updated to work solely with KRaft modespring-doc.cn

New Consumer Rebalance Protocol

Spring for Apache Kafka 4.0 supports Kafka 4.0’s new consumer rebalance protocol - KIP-848. For details, see New Consumer Rebalace Protocol docs.spring-doc.cn

Support multi-value header

The DefaultKafkaHeaderMapper and SimpleKafkaHeaderMapper support multi-value header mapping for Kafka records. More details are available in Support multi-value header mapping.spring-doc.cn