I have a standard spring kafka setup as follows,
@Bean
public ConcurrentKafkaListenerContainerFactory<String, String> feedbackStreamListenerContainerFactory() {
ConcurrentKafkaListenerContainerFactory<String, String> factory = new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactory());
return factory;
}
@KafkaListener(topics = ("my-topic"),groupId = ("groupId"),containerFactory = "listenerContainerFactory")
public void myListener(@Payload String message) {
System.out.println("Received Message : " + message);
// do some heavy processing
}
Now I need to have custom logging (generate logs from my app) on 3 scenarios,
See KafkaEvent
implementations: https://docs.spring.io/spring-kafka/docs/current/reference/html/#events .
So, when you catch ConsumerFailedToStartEvent
in the @EventListener
, you can log whatever you want and so on with the ConsumerStartedEvent
.
There is no even for deserialization issues, but you definitely can use a GenericErrorHandler
to log something when error from the consumer happens: https://docs.spring.io/spring-kafka/docs/current/reference/html/#annotation-error-handling
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.