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.1! |
What’s new?
What’s New in 3.2 Since 3.1
This section covers the changes made from version 3.1 to version 3.2. For changes in earlier version, see Change History.
Kafka Client Version
This version requires 3.7.0 kafka-clients
.
The 3.7.0 version of Kafka client introduces the new consumer group protocol.
Fore more details and it’s limitations see KIP-848.
The new consumer group protocol is an early access release and not meant to be used in production.
It is only recommended to use for testing purposes in this version.
Therefore, Spring for Apache Kafka supports this new consumer group protocol only to the extent of such testing level support available in the kafka-client
itself.
By default, Spring for Apache Kafka uses the classic consumer group protocol and when testing the new consumer group protocol, that needs to be opted-in via the group.protocol
property on the consumer.
Testing Support Changes
The kraft
mode is disabled in EmbeddedKafka
by default and users wanting to use the kraft
mode must enable it.
This is due to certain instabilities observed while using EmbeddedKafka
in kraft
mode, especially when testing the new consumer group protocol.
The new consumer group protocol is only supported in kraft
mode and because of this, when testing the new protocol, that needs to be done against a real Kafka cluster and not the one based on the KafkaClusterTestKit
, which EmbeddedKafka
is based upon.
In addition, there were some other race conditions observed, while running multiple KafkaListener
methods with EmbeddedKafka
in kraft
mode.
Until these issues are resolved, the kraft
default on EmbeddedKafka
will remain as false
.
Kafka Streams Interactive Query Support
A new API KafkaStreamsInteractiveQuerySupport
for accessing queryable stores used in Kafka Streams interactive queries.
See Kafka Streams Interactive Support for more details.
TransactionIdSuffixStrategy
A new TransactionIdSuffixStrategy
interface was introduced to manage transactional.id
suffix.
The default implementation is DefaultTransactionIdSuffixStrategy
when setting maxCache
greater than zero can reuse transactional.id
within a specific range, otherwise suffixes will be generated on the fly by incrementing a counter.
See Fixed TransactionIdSuffix for more information.
Async @KafkaListener Return
@KafkaListener
(and @KafkaHandler
) methods can now return asynchronous return types include CompletableFuture<?>
, Mono<?>
and Kotlin suspend
functions.
See Async Returns for more information.
Routing of messages to custom DLTs based on thrown exceptions
It’s now possible to redirect messages to the custom DLTs based on the type of the exception, which has been thrown during the message processing.
Rules for the redirection are set either via the RetryableTopic.exceptionBasedDltRouting
or the RetryTopicConfigurationBuilder.dltRoutingRules
.
Custom DLTs are created automatically as well as other retry and dead-letter topics.
See Routing of messages to custom DLTs based on thrown exceptions for more information.
Deprecating ContainerProperties transactionManager property
Deprecating the transactionManager
property in ContainerProperties
in favor of KafkaAwareTransactionManager
, a narrower type compared to the general PlatformTransactionManager
. See ContainerProperties and Transaction Synchronization.
After Rollback Processing
A new AfterRollbackProcessor
API processBatch
is provided.
See After-rollback Processor for more information.
Change @RetryableTopic SameIntervalTopicReuseStrategy default value
Change @RetryableTopic
property SameIntervalTopicReuseStrategy
default value to SINGLE_TOPIC
.
See Single Topic for maxInterval Exponential Delay.
Non-blocking retries support class level @KafkaListener
Non-blocking retries support @KafkaListener on a Class. See Non-Blocking Retries.
Support process @RetryableTopic on a class in RetryTopicConfigurationProvider.
Provides a new public API to find RetryTopicConfiguration
.
See Find RetryTopicConfiguration
RetryTopicConfigurer support process MultiMethodKafkaListenerEndpoint.
The RetryTopicConfigurer
support process and register MultiMethodKafkaListenerEndpoint
.
The MultiMethodKafkaListenerEndpoint
provides getter/setter
for properties defaultMethod
and methods
.
Modify the EndpointCustomizer
that strictly for MethodKafkaListenerEndpoint
types.
The EndpointHandlerMethod
add new constructors construct an instance for the provided bean.
Provides new class EndpointHandlerMultiMethod
to handler multi method for retrying endpoints.
New API method to seek to an offset based on a user provided function
ConsumerCallback
provides a new API to seek to an offset based on a user-defined function, which takes the current offset in the consumer as an argument.
See Seek API Docs for more details.
@PartitionOffset support for SeekPosition
Adding seekPosition
property to @PartitionOffset
support for TopicPartitionOffset.SeekPosition
.
See manual-assignment for more details.
New constructor in TopicPartitionOffset that accepts a function to compute the offset to seek to
TopicPartitionOffset
has a new constructor that takes a user-provided function to compute the offset to seek to.
When this constructor is used, the framework calls the function with the input argument of the current consumer offset position.
See Seek API Docs for more details.
Spring Boot application name as default client ID prefix
For Spring Boot applications which define an application name, this name is now used as a default prefix for auto-generated client IDs for certain client types. See Default client ID prefixes for more details.
Enhanced Retrieval of MessageListenerContainers
ListenerContainerRegistry
provides two new API’s dynamically find and filter MessageListenerContainer
instances.
getListenerContainersMatching(Predicate<String> idMatcher)
to filter by ID and the other is
getListenerContainersMatching(BiPredicate<String, MessageListenerContainer> matcher)
to filter by ID and container properties.
See @KafkaListener
Lifecycle Management’s API Docs for more information.
Enhanced observation by providing more tracing tags
KafkaTemplateObservation
provides more tracing tags(low cardinality).
KafkaListenerObservation
provides a new API to find high cardinality key names and more tracing tags(high or low cardinality).
See Micrometer Observation