spring-kafka icon indicating copy to clipboard operation
spring-kafka copied to clipboard

Add an option to only commit consumer offsets for records that are not filtered out using RecordFilterStrategy

Open geertvb opened this issue 1 year ago • 8 comments

Expected Behavior

When using a RecordFilterStrategy in combination with an AckMode like RECORD, only the consumer offsets of the records that have been handled, should be committed.

Suggestion: Add a new AckMode = RECORD_FILTERED that commits the offset only when a record is not filtered out.

Current Behavior

When using ack-mode: RECORD, the offset of every record is committed to Kafka even if it was filtered out.

Context

The synchronous commit of consumer record offset is an expensive operation. It slows down record consumption unnecessarily in case the consumer is only interested in a small percentage of the records and still wants every record that is processed to be committed.

geertvb avatar Oct 18 '24 10:10 geertvb

@geertvb Thanks for the report. This is almost like a new feature that we need to think through. We are so close to an RC for the 3.3.0 release. I think we need to postpone these types of changes at this point in our release cycle to the next minor version (3.4.x).

sobychacko avatar Oct 18 '24 13:10 sobychacko

Hi @sobychacko, thanks for the quick response and considering it as a feature for one of the next releases. For the time being we work around the issue by using a pure kafka-client ConsumerInterceptor.

geertvb avatar Oct 21 '24 06:10 geertvb

Hi @sobychacko , just wanted to check if this is ready for pickup now or if its already been done ?

Sauhardstark avatar Aug 16 '25 12:08 Sauhardstark

@Sauhardstark We haven't gotten to this yet, but if you want to contribute a PR, that would be appreciated. Thanks!

sobychacko avatar Aug 19 '25 16:08 sobychacko

Hi @sobychacko, I'd like to work on this issue if it's available. Could you please assign this issue to me? Thanks!

(I have already looked into the source code)

Chaedie avatar Sep 07 '25 08:09 Chaedie

Hi @Chaedie, please go ahead and submit a PR.

sobychacko avatar Sep 08 '25 01:09 sobychacko

@Chaedie Any updates on this issue? No problem if you are not ready to send a PR, but we have the RC release happening next week, so if you are in the middle of this PR, this might be the time to submit a PR.

sobychacko avatar Oct 15 '25 15:10 sobychacko

@sobychacko Thanks for the reminder. I already implemented the code. But I've been too shy to open the PR... 😅 I'll open a PR within the next 24 hours.

Chaedie avatar Oct 15 '25 22:10 Chaedie