In the context of a microservice architecture, a message driven, asynchronous, event based design seems to be gaining popularity (see here and here for some examples, as well as the Reactive Manifesto - Message Driven trait) as opposed to a synchronous (possibly REST based) mechanism.
Taking that context and imagining an overly simplified ordering system, as depicted below:
and the following message flow:
- Order is placed from some source (web/mobile etc.)
- Order service accepts order and publishes a
CreateOrderEvent
- The InventoryService reacts on the
CreateOrderEvent
, does some inventory stuff and publishes aInventoryUpdatedEvent
when it's done - The Invoice service then reacts to the
InventoryUpdatedEvent
, sends an invoice and publishes aEmailInvoiceEvent
All services are up and we happily process orders... Everyone is happy. Then, the Inventory service goes down for some reason 😬
Assuming that the events on the event bus are flowing in a "non blocking" manor. I.e. the messages are being published to a central topic and do not pile up on a queue if no service is reading from it (what I'm trying to convey is an event bus where, if the event is published on the bus, it would flow "straight through" and not queue up - ignore what messaging platform/technology is used at this point). That would mean that if the Inventory service were down for 5 minutes, the CreateOrderEvent
's passing through the event bus during that time are now "gone" or not seen by the Inventory service because in our overly simplified system, no other system is interested in those events.
My question then is: How does the Inventory service (and the system as a whole) restore state in a way that no orders are missed/not processed?