What’s New in 2.5 Since 2.4
This section covers the changes made from version 2.4 to version 2.5. For changes in earlier version, see [history].
Also see [new-in-sik].
Consumer/Producer Factory Changes
The default consumer and producer factories can now invoke a callback whenever a consumer or producer is created or closed. Implementations for native Micrometer metrics are provided. See [factory-listeners] for more information.
You can now change bootstrap server properties at runtime, enabling failover to another Kafka cluster. See [connecting] for more information.
You can now update the configuration map after the DefaultKafkaProducerFactory has been created.
This might be useful, for example, if you have to update SSL key/trust store locations after a credentials change.
See [producer-factory] for more information.
StreamsBuilderFactoryBean Changes
The factory bean can now invoke a callback whenever a KafkaStreams created or destroyed.
An Implementation for native Micrometer metrics is provided.
See [streams-micrometer] for more information.
Delivery Attempts Header
There is now an option to to add a header which tracks delivery attempts when using certain error handlers and after rollback processors. See [delivery-header] for more information.
@KafkaListener Changes
Default reply headers will now be populated automatically if needed when a @KafkaListener return type is Message<?>.
See [reply-message] for more information.
The KafkaHeaders.RECEIVED_MESSAGE_KEY is no longer populated with a null value when the incoming record has a null key; the header is omitted altogether.
@KafkaListener methods can now specify a ConsumerRecordMetadata parameter instead of using discrete headers for metadata such as topic, partition, etc.
See [consumer-record-metadata] for more information.
Listener Container Changes
The assignmentCommitOption container property is now LATEST_ONLY_NO_TX by default.
See [container-props] for more information.
The subBatchPerPartition container property is now true by default when using transactions.
See [transactions] for more information.
A new RecoveringBatchErrorHandler is now provided.
See [recovering-batch-eh] for more information.
Static group membership is now supported. See [message-listener-container] for more information.
When incremental/cooperative rebalancing is configured, if offsets fail to commit with a non-fatal RebalanceInProgressException, the container will attempt to re-commit the offsets for the partitions that remain assigned to this instance after the rebalance is completed.
The default error handler is now the SeekToCurrentErrorHandler for record listeners and RecoveringBatchErrorHandler for batch listeners.
See [error-handlers] for more information.
You can now control the level at which exceptions intentionally thrown by standard error handlers are logged. See [error-handlers] for more information.
The getAssignmentsByClientId() method has been added, making it easier to determine which consumers in a concurrent container are assigned which partition(s).
See [container-props] for more information.
You can now suppress logging entire ConsumerRecord s in error, debug logs etc.
See onlyLogRecordMetadata in [container-props].
Various error handlers (that extend FailedRecordProcessor) and the DefaultAfterRollbackProcessor now reset the BackOff if recovery fails.
See [seek-to-current], [recovering-batch-eh], [dead-letters] and [after-rollback] for more information.
KafkaTemplate Changes
The KafkaTemplate can now maintain micrometer timers.
See [micrometer] for more information.
The KafkaTemplate can now be configured with ProducerConfig properties to override those in the producer factory.
See [kafka-template] for more information.
A RoutingKafkaTemplate has now been provided.
See [routing-template] for more information.
You can now use KafkaSendCallback instead of ListenerFutureCallback to get a narrower exception, making it easier to extract the failed ProducerRecord.
See [kafka-template] for more information.
Kafka String Serializer/Deserializer
New ToStringSerializer/StringDeserializer s as well as an associated SerDe are now provided.
See [string-serde] for more information.
JsonDeserializer
The JsonDeserializer now has more flexibility to determine the deserialization type.
See [serdes-type-methods] for more information.
Delegating Serializer/Deserializer
The DelegatingSerializer can now handle "standard" types, when the outbound record has no header.
See [delegating-serialization] for more information.
Testing Changes
The KafkaTestUtils.consumerProps() helper record now sets ConsumerConfig.AUTO_OFFSET_RESET_CONFIG to earliest by default.
See [junit] for more information.