-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds the ability to add record interceptors instead of override them #3542
Comments
Thank for the report! |
No problem, this is not urgent. I just wanted this to hopefully be fixed in the future. Thank you for answering so quickly. |
@Nyamiou public class TestRecordInterceptor<K,V> implements RecordInterceptor<K, V> {
private final List<RecordInterceptor<K, V>> children = new ArrayList<>();
public void addRecordInterceptor(RecordInterceptor<K, V> interceptor) {
this.children.add(interceptor);
}
@Override
public ConsumerRecord<K, V> intercept(ConsumerRecord<K, V> record, Consumer<K, V> consumer) {
ConsumerRecord<K, V> invokedRecord = record;
for (RecordInterceptor<K, V> child : children) {
invokedRecord = child.intercept(invokedRecord, consumer);
}
return invokedRecord;
}
} |
Right, @chickenchickenlove , that will work for some use-case. |
I see! |
Expected Behavior
I'm using a Spring Cloud Steam
ListenerContainerCustomizer
to customize aAbstractMessageListenerContainer
in order to add a record interceptor. I would expect to be able to add a record interceptor at the last position, or to be able to get the current record interceptor, create aCompositeRecordInterceptor
to do the same thing and then set it (either is fine).Current Behavior
The issue I have is that only
setRecordInterceptor(...)
is public, notgetRecordInterceptor()
and there is noaddRecordInterceptor(...)
either. I would like to keep the existing record interceptors there and just add mine in last position but there seem to be no easy way to do this.Context
I have a code similar to this:
That I want to use in a small company internal library, but I don't want to remove the other projects the ability to use their own record interceptors.
I tried to use Spring Cloud Steam
ChannelInterceptor
(withGlobalChannelInterceptor
) to achieve the thing I wanted, but they callafterSendCompletion(...)
after each attempts, while the record interceptorafterRecord(...)
is called after all attempts. Also they do not allow to modify headers.The text was updated successfully, but these errors were encountered: