This version is still in development and is not considered stable yet. For the latest stable version, please use Spring for Apache Kafka 4.0.4!

What’s new?

What’s New in 4.1 Since 4.0

This section covers the changes made from version 4.0 to version 4.1. For changes in earlier versions, see Change History.

@KafkaListener Changes

The @KafkaListener annotation now supports an ackMode attribute, allowing individual listeners to override the container factory’s default acknowledgment mode without creating separate container factory beans. The attribute also supports SpEL expressions and property placeholders. See @KafkaListener Annotation for more information.

Share Consumer Error Handling

Share consumer containers now provide configurable error handling:

  • Poll-level: RecordDeserializationException and CorruptRecordException from poll() are caught so the consumer thread continues; undeserializable records are REJECTed and the next poll proceeds.

  • Listener-level: A ShareConsumerRecordRecoverer interface decides whether to ACCEPT, RELEASE, or REJECT when the listener throws. The default is ShareConsumerRecordRecoverer.REJECTING; RELEASING is also available. You can set a custom recoverer on the factory or container.

  • See Share consumer error handling in the Kafka Queues documentation.

ShareAcknowledgment.renew()

ShareAcknowledgment now supports renew() to extend the acquisition lock when processing exceeds the broker’s lock duration (KIP-1222, Kafka 4.2). See ShareAcknowledgment API in the Kafka Queues documentation for details.

RetryTopicConfigurationBuilder Default Strategy Change

The default value of sameIntervalTopicReuseStrategy in RetryTopicConfigurationBuilder has been changed from MULTIPLE_TOPICS to SINGLE_TOPIC to align with the @RetryableTopic annotation default. See Topic Naming for more information.