Spring Consumer Replay Kafka

I am using Spring Kafka consumer, which extracts messages from threads and transfers them to db. If the failure condition is fulfilled, say, for example, that db is unavailable, does the kafka consumer library make a retry mechanism? If so, is there a way to set different retry intervals, such as the 1st retry should be done after 5 minutes, 2nd after 30 minutes, 3rd after 1 hour, etc.

+4
source share
1 answer

Spring Kafka comes with RetryingMessageListenerAdapterand RetryingAcknowledgingMessageListenerAdapter. If you use @KafkaListener, you can supply AbstractKafkaListenerContainerFactoryusing RetryTemplate. And the latter can be entered by any user RetryPolicyand BackOffPolicyfrom the Spring Retry project:

https://docs.spring.io/spring-kafka/docs/2.0.0.RELEASE/reference/html/_reference.html#_retrying_deliveries

Also keep in mind that 2.0there is transaction support in Spring Kafka from the version , based on this in Apache Kafka 0.11.x.x:

https://docs.spring.io/spring-kafka/docs/2.0.0.RELEASE/reference/html/_reference.html#transactions

+2
source

Source: https://habr.com/ru/post/1686774/


All Articles