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! |
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.
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:
-
All ZooKeeper-based functionality has been removed as Kafka 4.0 fully transitions to KRaft mode
-
The ZooKeeper dependency has been removed from the project
-
The embedded Kafka test framework now exclusively uses KRaft mode
-
The
EmbeddedKafkaZKBroker
class has been removed, and all functionality is now handled byEmbeddedKafkaKraftBroker
Embedded Kafka Test Framework Changes
The test infrastructure has been significantly updated:
-
The
EmbeddedKafkaRule
JUnit 4 rule has been removed -
The
@EmbeddedKafka
annotation has been simplified with the removal of ZooKeeper-related properties: -
The
kraft
property has been removed as KRaft mode is now the only option -
ZooKeeper-specific properties like
zookeeperPort
,zkConnectionTimeout
, andzkSessionTimeout
have been removed -
KafkaClusterTestKit imports now use new packages for KRaft mode
-
Some tests have been updated to address limitations with static port assignments in KRaft mode
-
Adjustments have been made to replication factors in tests to accommodate KRaft requirements
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.
Producer Interface Updates
New methods from the Kafka Producer interface have been implemented:
-
registerMetricForSubscription
-
unregisterMetricFromSubscription
Removed Deprecated Functionality
Several deprecated items have been removed:
-
The deprecated
partitioner
classes have been removed from runtime hints -
The deprecated
sendOffsetsToTransaction
method that usedString consumerGroupId
has been removed
Kafka Streams API Changes
-
KafkaStreamBrancher
has been updated to use the newsplit()
andbranch()
methods instead of the deprecatedbranch()
method -
The
DeserializationExceptionHandler
has been updated to use the newErrorHandlerContext
Internal API Updates related to Apache Kafka 4.0.0
-
The
BrokerAddress
class now usesorg.apache.kafka.server.network.BrokerEndPoint
instead of the deprecatedkafka.cluster.BrokerEndPoint
-
The
GlobalEmbeddedKafkaTestExecutionListener
has been updated to work solely with KRaft mode
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.
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.