Search code examples
spring-bootapache-kafkaspring-kafkaspring-aop

Intercept kafka poll request with SpringAOP


I would like to intercept the kafka poll request in order to log some informations like response time, available message number. I used springAOP without any success. I'm already using @KafkaListener to consume message one by one but i would like to track also the poll request. Has anyone done something like that before?


Solution

  • You probably can do that implementing (via extension) a DefaultKafkaConsumerFactory. In the overridden createConsumer() method you wrap the super result into the mentioned AOP proxy and intercept via your MethodInterceptor the poll(Duration) call.