DEV Community

Discussion on: Data Consistency in the Microservice Architecture

Collapse
 
miketalbot profile image
Mike Talbot ⭐ • Edited

Really great article!

What's your goto method of dealing with multiple message delivery in "at least once" systems?

Collapse
 
vudodov profile image
Valerii Udodov

Hey Mike, that's a really good question.

There's a lot of opinions around exact-once delivery. A part of community convinced it is impossible at all. I wouldn't necessary agree with that, but there are certain scenarios when it is unachievable.

Said that I'd say it is strongly depend on exact mechanism of message transportation. In most cases on used message broker. And obviously surrounding architecture as well.

Speaking of a general go-to, I'd make a consumer-service responsible for message validation. I'd suggest making services idempotent. How? Well, hate to say it, but it depends again...

As a general go-to probably nothing really fancy.
Keep track of latest incoming message ids or message payload hashes (something that is easy to calculate). And validate each new message against them. How long each hash/id record has to live (be stored on a receiving end)? Ultimately depends on for how long we can expect a duplicated message to arrive.

Hope it answers your question.