I have multiple microservices, each responsible for one part of the domain, and each with its own data store. For the sake of example, let's say that's User, Order, Payment and Company. I want these microservices to be loosely coupled, and to reduce direct dependencies between them.
However, I have some complex core business process, order creation for example, that involves all the microservices. The natural thing to do would be to handle order creation within the Order microservice, and make the Order microservice depend on every other microservice. However we have other use cases where the other microservices will have to depend on the order microservice.
My questions are:
- Should I even be scared of circular dependencies when dealing with a microservice architecture? Or are they just an unavoidable occurrence?
- Let's say I create a separate microservice to handle order creation. Would this microservice have access to the data stores of other microservices? Or would it depend on every other microservice?
- Let's say I try managing the order creation process using events instead of direct dependencies. Is it alright if the same microservice handles multiple events for the same business process? How important is being able to replay events? What are some pitfalls I should think about?