Microservices: how to handle foreign key relationships

前端 未结 4 2095
温柔的废话
温柔的废话 2021-01-29 20:14

Microservices architecture suggest that each service should handle it\'s own data. Hence any service (Service A) dependent on data owned by other service (service B) should acce

4条回答
  •  青春惊慌失措
    2021-01-29 21:01

    first solution: API Composition

     Implement a query by defining an API Composer, which invoking the
     services that own the data and performs an in-memory join of the
     results
    

    second solution: CQRS

    Define a view database, which is a read-only replica that is designed to support that 
    query. The application keeps the replica up to data by subscribing to Domain events 
    published by the service that own the data.
    

提交回复
热议问题