Kafka in Spring Boot: Production Lessons

Kafka problems in Spring Boot rarely show up as errors. Events go missing after a successful database commit, consumers process the same message twice, and total lag looks healthy while one partition is stuck. These articles trace real incidents and the fixes we tested.

All articles on this page are also collected in a Medium list you can save and follow.

Start here

Delivery and consistency

Consumers, lag and partitions

Schemas and local setup

RabbitMQ

Also on bytzecho.com

Versions of these articles on this site, with extended code and notes.

Frequently asked questions

Why does Spring Boot save to the database but the Kafka event never arrives?

Writing to the database and sending to Kafka are two separate operations, so one can succeed while the other fails. The transactional outbox pattern writes the event to an outbox table in the same database transaction and relays it to Kafka afterwards. See Spring Boot Saved the Order. Kafka Never Received the Event.

Why does a Kafka consumer process the same message twice?

Kafka consumers get at-least-once delivery by default: if a consumer fails or rebalances after processing but before committing the offset, the message is delivered again. Make the processing idempotent, for example by recording processed event IDs.

Can Kafka consumer lag look healthy while a partition is stuck?

Yes. Total lag across a topic can stay low while a single partition stops moving. Monitor lag per partition and alert on partitions whose offset stops advancing.

New articles are published on Medium first. Subscribe to the newsletter to get production lessons by email.