Example for XmasDev 2023 conference
When we have to deal with distributed systems we need to balance three forces
- Communication (sync vs async)
- Persistence (strong vs eventually)
- Workflow (orchestrator vs choreography)
When your business workflow depends by more than one microservice, you have to manage it. A Saga is a Long Running Process that involves all the microservices requested. There are two kind of Sagas
- Orchestrator
- Choreography
As you know, in Software Architecture, all is a Trade-Off, and which kind of Saga you choose is a trade-off. For this example I choose- Asynchronous communication
- Eventually Consistency
- Orchestrator workflow
In this solution you can find:
XmasBlazorexample of Modular Architecture with lazy loading in FrontEnd
A series of microservices:XmasSagasto manage the SagaXmasReceveirdelegate to receive the xmas letter from childrenXmasWarehousesdelegate to prepare the xmas presentsXmasLogisticsdelegate to load the Santa Claus sleigh to send the presents to the children You need .NET 8 installed to run the examples.
Is a pattern used to split the process of writing from the process of reading the data. It was introduced by Greg Young, and, as every pattern, is not a "one size fit all" solution, so please, handle with carefully!!!
It's an open-source project to help you implementing Domain-Driven Design with Event-Driven approach.
You can find more details here
You can find more examples here
Each microservice in this solution has its own ReadModel (MongoDb) and its own EventStore.
- Prepare Infrastructure: docker-compose up -d (inside docker folder)
- XmasSagas:
- docker build -t xmassagas .
- docker run --rm -p 5000:8080 --name xmassagas xmassagas
- XmasReceiver:
- docker build -t xmasreceiver .
- docker run --rm -p 5100:8080 --name xamsreceiver xmasreceiver
- XmasWarehouses:
- docker build -t xmaswarehouses .
- docker run --rm -p 5200:8080 --name xmaswarehouses xmaswarehouses
- XmasLogistics:
- docker build -t xmaslogistics .
- docker run --rm -p 5300:8080 --name xmaslogistics xmaslogistics
You can also use the docker-compose file for each microservice, instead of docker run