How to get the name of the topic outside the kafkalistener? #2666
-
Team, I have a retry bean
I need to log all the topic names in the listeners, in order to do this I added extra parameter in the listener as below
Since I have lots of Kafka listeners it is time consuming to add the extra parameter. Is there any other place where I can add Kindly let me know. Any leads are much appreciated. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
You don't need that header if you deal with
On the other hand it is not clear how you are going to build those listener methods logic if you are not going to propagate the value via method argument. When you talk about retry, you don't compare apples with apples: the retry (as well as listener instance) is created only once during configuration phase. |
Beta Was this translation helpful? Give feedback.
Yes, you can add a
RecordInterceptor
to catch the listener call.See
AbstractMessageListenerContainer
:So, probably in the impl you can set some
ThreadLocal
value and get access to it downstream in your business logic if the listener method.