views:

23

answers:

4

Hello,

Imagine we have 2 services: Product and Order. Based on my understanding of SOA, I know that each 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.

Now, imagine we have stored the product and order data independently inside Product and Order Services. In the Order Service, we can identify products by their ID.

My question is: With this architecture, how can I display the list of orders and product details on the "same" page?

My understanding is that I should get the list of OrderItems from OrderService. Each OrderItem has a ProductID. Now, if I make a separate call to ProductService to retrieve the details about each Product, that would be very inefficient.

How would you approach this problem?

Cheers, Mosh

A: 

SOA is just a buzz-phrase for deploying components behind web services. How many data stores you have is entirely up to you. In some cases it makes sense to have partitioned data behind individual components, and in other cases all the data lives behind one service, and in other cases many components that expose service interfaces connect to the same database via the database's connection protocol. Approach the problem by approaching the problem, not be imposing artificial constraints.

bmargulies
A: 

I don't think there is any principle in SOA that services should have separate data store. In general it is actually impractical. Yes you can have product and order service and the client can do the join using web service call as you said and this may be acceptable in some scenario. But that doesn't mean that you cannot have a specific service for a client if you already know the client's behaviour and performance requirements.
What I mean is that you should have a search service that returns orders and products with the join done in database. This is practical and would solve your business problem.

Pratik
I'm not an SOA expert, but I believe the idea of each Service having its own data store is a core principle in SOA. Services are not allowed to touch the data store each other directly. If they need data, they should ask the Service that encapsulates the data. This is to prevent changes to the schema of that data store breaking any other Services directly dependent on that.
Mosh
I have doing SOA for few years now. Services are autonomous but that doesn't mean they cannot share data store. In this particular case where products and orders are related then you will end up with a service with a fat surface area managing both entities (to satisfy your definition). In many enterprise core systems there is one data source (source of truth) and there can be multiple services that manages various entities of your data model. Consistency can be achieved by having a common business logic layer implementation for the various service interfaces.
Pratik
A: 

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

Mosh