Idempotence – Being able to do the same call many times and the result is the same. Use an alternative key in database and send the client id with the request. If you try multiple times you will get the first object you tried to store.
Immutability – Data is never destroyed. You can use CQRS (Command Query responsibility Segregation). Each command will have an add or delete.
- History of intent
- Metadata
- Insert-only data
Location independence – storage of data is not dependent on where it is stored
- Don’t rely on auto increment id in local databases
- Content base
Versioning – Code, Data and API.
- Code – Source control
- Data – migrate to evolve
- API – URL, Query string, additive structure.
Publish-Subscribe – Single publisher and multiple subscribers. Decoupling.
- Different kind of subscribers – Each need to receive the event.
- Same type of subscribers – Only one should receive the event.
- Dead letter queue – Messages that failed to be delivered.
- Commutative – a+b = b+a. Message handlers are commutative if the outcome of the message don’t depend on the order.
Commutative – the order dosen’t matter
Achieving consistency – commutative (can’t guarantee the order) and idempotence (can’t guarantee the number of times)
Why seperate Service
- Different release schedule
- Different data stores (relationship database and document database)
- Different load and needs to scale differently