Scenario #1
Scenario #2
Scenario #3
Scenario #4 (problems start...)
Scenario #n [many many variants of #4] ...
So I cannot make my mind around a clear criteria on how to use webservices in DDD when they make changes in their state.
Ideally, I would do the changes in my storage, and then having some kind of integration layer that replicates those changes in external databases or services, with events for example. However, most of times there is a read-after-write consistency requirement, where if you refresh after a operation returns, the right data is shown on screen (eg: the payment receipt that comes from the same webservice where the payment was done).
Another example: A screen allows to save the data about a book, however the book specifications is saved in a database, and the descriptions (in several languages) are saved in an external service. The operation has to be consistent, if a user click "Save" and refresh, the screen needs to show all together, cannot just show the specifications with old translations or not translations at all because they are being replicated to another database.
Which is a solid criteria to decide?
The answer is to read Life Beyond Distributed Transactions.
The short form is that trying to reliably coordinate writes at different locations is expensive. In most cases it is better to admit in your design that you can't be in all places at once, and invest in your handling of the consequences of that fact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With