Spring Kafka with Retry-After support

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”

Thinking in Mocks Is a Bad Way to Think

Teaching people to write tests by telling them to use mocks is a huge mistake. Mocks are useful in very limited situations. Most of the time, they do nothing more than let broken code pass unnoticed. The vast majority of everyday tests shouldn’t use mocks at all. Bold claim? I have code to back it up.

Czytaj dalej „Thinking in Mocks Is a Bad Way to Think”
Creative Commons License
Except where otherwise noted, the content by Piotr Kubowicz is licensed under a Creative Commons Attribution 4.0 International License.