Skip to content

Conversation

@Chaedie
Copy link
Contributor

@Chaedie Chaedie commented Oct 16, 2025

Issue: #3562

Summary

Add a new AckMode AckMode.RECORD_FILTERED.
It will commits offsets only for records that are not filtered by RecordFilterStrategy.

Problem

When RecordFilterStrategy is used with AckMode.RECORD, the container commits the offset for every record, including those filtered out (never delivered to the listener).
This causes unnecessary synchronous commits and can advance offsets for records that were effectively skipped.

Implementation

  • ContainerProperties.AckMode.RECORD_FILTERED
  • KafkaMessageListenerContainer: per-record commit path skips filtered records
  • FilteringAware + FilteringMessageListenerAdapter to expose filter results

Tests

  • RECORD vs RECORD_FILTERED behavior with/without filtering
  • Mixed partitions and all-filtered cases
  • Thread isolation test (recordFilteredModeShouldBeThreadIsolated) verifying independent adapter state per thread

I wasn’t fully confident about my code, so I hesitated to open this PR for a few weeks. 😅
Please feel free to review it — thank you!

@Chaedie Chaedie force-pushed the GH-3562-4 branch 2 times, most recently from dc6bc25 to c0bb203 Compare October 16, 2025 18:04
Copy link
Contributor

@sobychacko sobychacko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to use public modifier on test classes or methods any longer.

* @author Chaedong Im
* @see AckModeRecordWithFilteringTest
*/
public class AckModeRecordFilteredTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can drop public modifier from tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it. Thanks 😊


@SuppressWarnings({"unchecked", "deprecation"})
@Test
public void testRecordFilteredModeOnlyCommitsProcessedRecords() throws InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No public modifier needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it. Thanks 😊


@SuppressWarnings({"unchecked", "deprecation"})
@Test
public void testRecordFilteredModeWithAllRecordsFiltered() throws InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no public modifier needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it. Thanks 😊

* @author Chaedong Im
* @see AckModeRecordFilteredTest
*/
public class AckModeRecordWithFilteringTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No public modifier needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it. Thanks 😊

*/
RECORD,

/**
Copy link
Contributor

@sobychacko sobychacko Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add author tag to the class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed this class. I added author tag. Thanks 😊

Signed-off-by: Chaedong Im <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants