When we have multiple microservices in our product, they ought to communicate with each other in order to do various activities. So how should that be done. Imagine a scenario that your user does something on your mobile app which calls microservice A, which in turns call microservice B which calls microservice C and so on. So your microservice can become very tangled and messy. We need to avoid this.
So the better approach is first whatever clients you have, be it the web client, mobile app or any third party interacting with your product. They should preferably call a common API gateway which should call a BFF (Backend for Front End). In case you are not familiar with BFF, there is an excellent article by Sam Newman explaining Backend for Front End.
Now this BFF can call any microservice based on the functional use case. But what if it calls say Ordering Service and Ordering Service needs to call Catalog service. They should still not call each other directly to avoid above entanglement and messiness. Instead they should publish the messages/events to a message bus (RabbitMQ) and other services can subscribe to the message bus. That way communication is very neat.
Below is a good representation.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?