// RULES
Microservice rules
Best practices for microservices, one rule per page: why it matters, how to apply it and an example. They are grouped into checklists you can apply to a service.
6 rules of 70 · Clear filters
Events
- Consumed events have a schema
For every event it consumes, the service records the payload it relies on, so a publisher change that breaks it can be seen in advance.
HighChecked automatically
- Event consumers handle duplicates
Every consumed event can arrive more than once; processing it twice must not change the outcome.
HighChecked by hand
- Event schemas evolve compatibly
A change to a published event never breaks a consumer already reading it: fields are added, not renamed or removed.
HighChecked by hand
- Events are published through an outbox
A state change and the event that announces it are saved together, so one never happens without the other.
HighChecked by hand
- Messages that keep failing go to a dead-letter queue
A message the consumer cannot process is set aside after a few attempts, with an alert, so it neither blocks the queue nor disappears.
HighChecked by hand
- Published events have a schema
Every event the service publishes has a declared payload, so consumers code against a contract and not against samples.
HighChecked automatically