aspnetrun / run-aspnetcore-microservices

Microservices on .Net platforms which used ASP.NET Web API, Docker, RabbitMQ, MassTransit, Grpc, Yarp API Gateway, PostgreSQL, Redis, SQLite, SqlServer, Marten, Entity Framework Core, CQRS, MediatR, DDD, Vertical and Clean Architecture implementation with using latest features of .NET 8 and C# 12
https://www.udemy.com/course/microservices-architecture-and-implementation-on-dotnet/?couponCode=JUNE24
MIT License
2.53k stars 1.38k forks source link

Communication Between two microservices using ASP.Net Core WebApi #16

Closed kmuthugtk closed 3 years ago

kmuthugtk commented 3 years ago

I have two Microservices. First Service for Customers and Second service for Invoice Service.

In Invoice MicroService, I will save only CustomerId in Invoice services. Using this CustomerId, I would like to retrieve all the related data for Customer Microservice. But i don't know to communicate async.

Any please get me some ideas and examples

mehmetozkaya commented 3 years ago

You cant make async communicate in that case. this is the topic that data management in microservices. there are several best practices that you can use. my recommendation is duplicate customer data in invoice microservice and update customer data async when it is changed in customer microservice by triggering an event to event bus.

https://docs.microsoft.com/en-us/dotnet/architecture/cloud-native/distributed-data

https://developers.redhat.com/blog/2019/05/23/data-as-a-microservice-distributed-data-focused-integration/

https://blog.christianposta.com/microservices/the-hardest-part-about-microservices-data/