You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/filtering.adoc
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,3 +87,40 @@ public void listen(List<Thing> things) {
87
87
----
88
88
However, in this case, `IgnoreEmptyBatchRecordFilterStrategy` always returns empty list and return `false` as result of `ignoreEmptyBatch()`.
89
89
Thus `KafkaListener#listen(...)` always will be invoked.
90
+
91
+
== RECORD_FILTERED Acknowledgment Mode
92
+
93
+
Starting with version 3.1, the `RECORD_FILTERED` acknowledgment mode is available for use with filtered message listeners.
94
+
Unlike the standard filtering approach where filtered records are still committed, `RECORD_FILTERED` mode ensures that offsets for filtered records are not committed, allowing them to be reprocessed if needed.
95
+
96
+
Key characteristics:
97
+
98
+
* Auto-commit is automatically disabled when using `RECORD_FILTERED` mode
99
+
* Filtered records are tracked internally and excluded from offset commits
100
+
* Works with both single record and batch listeners
101
+
* Compatible with filtering adapters and record filter strategies
102
+
* Supports transactions
103
+
104
+
Example configuration:
105
+
106
+
[source, java]
107
+
----
108
+
@Bean
109
+
public ConcurrentKafkaListenerContainerFactory<String, String> kafkaListenerContainerFactory() {
// Only non-filtered messages will reach this method
121
+
// Filtered messages will not have their offsets committed
122
+
process(message);
123
+
}
124
+
----
125
+
126
+
When using `RECORD_FILTERED` mode, the framework automatically marks filtered records so their offsets are excluded from commits, ensuring they remain available for reprocessing in scenarios such as consumer restart or rebalancing.
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/message-listener-container.adoc
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -215,6 +215,7 @@ The `MessageListener` is called for each record.
215
215
The following lists describes the action taken by the container for each `AckMode` (when transactions are not being used):
216
216
217
217
* `RECORD`: Commit the offset when the listener returns after processing the record.
218
+
* `RECORD_FILTERED`: Like `RECORD`, but when a `RecordFilterStrategy` filters a record, that record's offset is not committed. Auto-commit is disabled. Filtered records are tracked and their offsets are excluded from commits to ensure they can be reprocessed if needed. Requires the use of a `RecordFilterStrategy`.
218
219
* `BATCH`: Commit the offset when all the records returned by the `poll()` have been processed.
219
220
* `TIME`: Commit the offset when all the records returned by the `poll()` have been processed, as long as the `ackTime` since the last commit has been exceeded.
220
221
* `COUNT`: Commit the offset when all the records returned by the `poll()` have been processed, as long as `ackCount` records have been received since the last commit.
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/antora/modules/ROOT/pages/whats-new.adoc
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,26 @@
1
1
= What's new?
2
2
3
+
[[whats-new-in-3-1-since-3-0]]
4
+
== What's New in 3.1 Since 3.0
5
+
:page-section-summary-toc: 1
6
+
7
+
This section covers the changes made from version 3.0 to version 3.1.
8
+
9
+
[[x31-record-filtered-ack-mode]]
10
+
=== RECORD_FILTERED Acknowledgment Mode
11
+
12
+
A new acknowledgment mode `RECORD_FILTERED` has been added that works in conjunction with record filtering.
13
+
Unlike standard filtering where filtered records are still committed, this mode excludes filtered record offsets from commits, ensuring they can be reprocessed if needed.
14
+
15
+
Key features:
16
+
* Automatically disables auto-commit
17
+
* Tracks filtered records and excludes their offsets from commits
18
+
* Works with both single record and batch listeners
19
+
* Supports transactions
20
+
* Compatible with existing filtering adapters and record filter strategies
21
+
22
+
See xref:kafka/receiving-messages/filtering.adoc#record-filtered-acknowledgment-mode[RECORD_FILTERED Acknowledgment Mode] for more details.
Copy file name to clipboardExpand all lines: spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/FilteringBatchMessageListenerAdapter.java
Copy file name to clipboardExpand all lines: spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/FilteringMessageListenerAdapter.java
0 commit comments