To guarantee exactly-once delivery, I would use idempotent writes and track message offsets carefully. With Kafka, you can enable exactly-once semantics using transactional producers and idempotent consumers. On the sink side, you assign each message a unique key and use a deduplication window to catch any replays. I would also implement checkpointing in the stream processor so we can replay from a known state after failure. For monitoring, I would set up lag metrics on the consumer group and alert on processing delays.
I have built this guarantee in production and the first thing I learned is that exactly-once is a contract with downstream consumers, not a property of the pipeline alone. The design starts with idempotency keys scoped to the consumer's use case — not a generic message ID. For Kafka, I use transactional producers with offset commits inside the same transaction, and I size the deduplication window based on the maximum observed retry interval under our worst incident — not a default TTL. The real cost is write amplification and increased P99 latency; on our highest-throughput pipeline we saw a forty percent latency increase, so we negotiated exactly-once only on the paths where downstream duplication caused financial impact. I also instrumented idempotency key collision rates as a first-class metric, because silent key collisions are how this guarantee fails without alerting.