3

We´re planning to use the Microservice Architecture in our next application. I wanted to know if it´s a common practise to have a same domain entity for every related microservice. For example, there is a customer. A customer consists of multiple users and one company. They are existing in a customer service. Then there is a warehouse service. A warehouse can have different customers in different roles. So the warehosue entities holds keys to the customers.

In front of those two microservices there is an API gateway. Now when showing a screen with warehouses we need also the information about the customers from the customer service. So the API gateway could handle this, meaning fetch the warehouses and then the related customers. But then we connect two services via the API gateway. Is it a better way to hold the customers with specific attributes also in the warehouse service? But this is just necessary for view/UI specific use cases? Is this a correct way to bring "view logic" to the services?

DehMotth
  • 679
  • 3
  • 12
  • 21
  • We have a very similar problem. Would be great if you could share your learnings? Is it better to duplicate the profile data in both the micro-services (via events)? Or should UI/gateway be responsible to fetch data at runtime via synchronous API calls. I personally am a bit biased towards duplicating the relevant customer's profile data in the warehouse service as it removes a dependency and would serve the end-user better if customer service was down. But still not sure if that;s the best practice. – Abdul Qadir Nov 26 '19 at 17:07

2 Answers2

2

You might implement this in different ways. The warehouse micro-service may consume data from the customer micro-service and enrich its response having everything in it for the presentation. Or the presentation may consist of several areas which are loaded from different micro-services each presenting its section.

Simon Sadetsky
  • 544
  • 2
  • 5
0

Try to have as much microservice as you can based up single responsiblity system.

Create a API service and allow it to generate events which will be then consumed by other microservices and will provide results based on required parameters.

Now API can club the data and can respond back with the required format.

having multiple microservices will help you in scaling up and down , if you had only 2 microservices it is more or less like a monolithic services only.

Take the decision, considering future in mind.

Vijay Parmar
  • 795
  • 4
  • 13