How do microservices communicate with each other or exchange data in Spring Boot?

I am implementing my microservices system with eureka and gateway with Java spring boot.

Currently I have 2 services: Product and User. In the products table at Product service, the field createdBy is the userId in User service.

The problem I am facing here is when I get the product list in Product service, each product will come with creator information, how can I get it from User service? Will I have to iterate through the product list and make api calls to the User service to get user information?

If I want to get 100 products it will take 100 calls to User service, that will definitely be bad, how do I solve this case.

Thanks everyone

i searched for solutions but none worked other than making an API call to the User service

  • Don’t embed the user in the response, only reference it by id.

    – 

  • you dont need to call User api 100 times, you could just create an enpoint that can get List of ids, and search by Id

    – 

Leave a Comment