The Spring Kafka library provides error handling via a well-established exponential back-off mechanism. However, if the error is HTTP 429 “Too Many Requests” (that is, rate limiting), ordinary exponential increases in the delay between retries are a bit like a brute-force attack: we either waste resources by retrying too early, or waste time by waiting too long. It would be better to wait exactly as long as the server tells us to.
In the following sections, I will show how to approach the implementation. In short, it boils down to writing a single, uncomplicated class.
Czytaj dalej „Spring Kafka with Retry-After support”