servicesoa

SOA: Joining data across multiple services


Each SOA (Service-Oriented Architecture) service can have its own data store (a separate database, or a group of tables in the same database). But no service is allowed to touch the data store of another service directly.

Imagine Product and Order services store data independently. In Order we identify products by ID.

How can I display the list of orders and product details?

I should get the list of OrderItems from Order. Each OrderItem has a ProductID. If I make a separate call to Product to retrieve the details about each product, that would be inefficient.


Solution

  • I did some research and found 2 different solutions for this.

    1- Services can cache data of other Services locally. But this requires a pub/sub mechanism, so any changes in the source of the data should be published so the subscribing Services can update their local cache. This is costly to implement, but is the fastest solution because the Service has the required data locally. It also increases the availability of a Service by preventing it from being dependent to the data of other Services. In other words, if the other Service is not available, it can still do its job by its cache data.

    2- Alternatively, a Service can query a "list" of objects from another Service by supplying a list of identifiers. This prevents a separate call to be made to the target service to get the details of a given object. This is easier to implement but performance-wise, is not as fast as solution 1. Also, in case the target Service is not available, the source Service cannot do its job.

    Hope this helps others who have come across this issue.

    Mosh