4 ms·
Tongue-in-cheek answer (but really what I believe): Don't use microservices. Short answer: It's extremely difficult and, there isn't always a good solution.
by latch 5y ago
Tongue-in-cheek answer (but really what I believe):
Don't use microservices.
Short answer:
It's extremely difficult and, there isn't always a good solution. Different approaches are used on a _per consumer_ basis. That's the gist of what you want to hear.
Long answer:
In some cases ordering and lost messages don't matter so much, so any failed messages can just be thrown out.
For some queues lost messages matters, but not ordering. So you can put the message at the back of the queue (possibly delayed if that's support), so you don't block other messages.
Partitioning helps isolated poison messages to a vertical (e.g., customer_id).
Always adding id and timestamp to each message can let consumers behave more smartly (e.g. throwing away out of order or already processed messages).
But when none of that helps and ordering and delivery matter (which I think will make up most cases for any non-trivial system)...I'd love to know too. Good alerts to wake up developers?
Then there's how to scale this and making it reliable What's the ordering guarantee across N consumers? What if a consumer nack's a message. What if there's prefetching?