I find a lot of resources regarding strong consistency versus eventual consistency, and when to choose one or the other.
I'm wondering how and when you would have both together. Consider this specific scenario:
- Order service receives and stores order to database.
- Order service sends OrderReceived message on the message bus.
- Another service (or even another aggregate in Order service) receives message and performs an operation.
We really don't want to store the order successfully then fail to deliver message on bus, or we risk downstream services never receiving the update, right?
Am I wrong in thinking that operations 1 and 2 should almost always (there are probably exceptions to this case) be transactionally consistent?
I'm asking because my teammates and I are inexperienced in this area, and we have services that do not put operations 1 and 2 in transactions.
EDIT: More generally speaking, if you have this saga scenario:
- Service A
- Performs operation A successfully
- Communicates update with message A
- Service B (after receiving message A)
- Performs operation B successfully
- Communicates update with message B
- Service C (after receiving message B)
- Fails to perform operation C
- Communicates failure
- Service A and B performs compensating actions
My assumption is that while the entire workflow must be eventually consistent, the internal/local operations described (the 1s and 2s) must be transactionally consistent.