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
GH-3542: API for adding record interceptors instead of overriding them (#3937)
Fixes: #3542
* Providing the ability to add record interceptors instead of overriding them
Change `RecordInterceptor` to `List<RecordInterceptor>` in
`MessageListenerContainer` will allow the addition of multiple `RecordInterceptor`
instances instead of overriding the existing one
Currently, only a single `RecordInterceptor` is supported.
Users may want to register multiple `RecordInterceptors`.
There are some workarounds, but they are not clean or ideal solutions.
By supporting `List<RecordInterceptor`>, users can add their own
interceptors via `setRecordInterceptor(...)`.
* Adding new API for addRecordInterceptor.
* Addressing PR review
Signed-off-by: Sanghyeok An <[email protected]>
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/message-listener-container.adoc
+29-1Lines changed: 29 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,35 @@ IMPORTANT: If the interceptor mutates the record (by creating a new one), the `t
22
22
23
23
The `CompositeRecordInterceptor` and `CompositeBatchInterceptor` can be used to invoke multiple interceptors.
24
24
25
+
Starting with version 4.0, `AbstractMessageListenerContainer` exposes `getRecordInterceptor()` as a public method.
26
+
If the returned interceptor is an instance of `CompositeRecordInterceptor`, additional `RecordInterceptor` instances can be added to it even after the container instance extending `AbstractMessageListenerContainer` has been created and a `RecordInterceptor` has already been configured.
27
+
The following example shows how to do so:
28
+
29
+
[source, java]
30
+
----
31
+
public void configureRecordInterceptor(KafkaMessageListenerContainer<Integer, String> container) {
0 commit comments