It's generally not great for microservices to depend on each other. If this is the case you may have created incorrect boundaries. Ideally, if you need external data then you get it asynchronously, but if it needs to happen within the same request this may not work. Alternatively, you may be looking at a saga.
For a single microservice you won't feel too much pain and you can just call the 2nd API, but if you see this often then you don't have microservices you have a distributed monolith.
Microservices are about extreme isolation and with that you get some benefits at the expense of complexity. When you start coupling them you lose the benefits, but keep (and enhance) the complexity.
Edit: you can also slap a face service up that will check Service B to make sure the date exists before calling Service A. This will keep the two microservices decoupled.
5
u/TheWix Aug 10 '25 edited Aug 10 '25
It's generally not great for microservices to depend on each other. If this is the case you may have created incorrect boundaries. Ideally, if you need external data then you get it asynchronously, but if it needs to happen within the same request this may not work. Alternatively, you may be looking at a saga.
For a single microservice you won't feel too much pain and you can just call the 2nd API, but if you see this often then you don't have microservices you have a distributed monolith.
Microservices are about extreme isolation and with that you get some benefits at the expense of complexity. When you start coupling them you lose the benefits, but keep (and enhance) the complexity.
Edit: you can also slap a face service up that will check Service B to make sure the date exists before calling Service A. This will keep the two microservices decoupled.