views:

335

answers:

2

Hi everyone !

I am moving my architecture from coupled one to SOA (WCF) loosely coupled. I have several services which communicate with each others. How would you synchronize the business instances between the services?

I see two scenarios here:

  1. All the business objects are created in only one service, let's call it MainService and it's the only one who have access to all of the changes made to the objects. The service is in charge of the update of the objects in the database. Any update of an object raises a notification. Others services register to the events they need and get notified accordingly. I call it the centralized approach.

    + Notify service as soon as a change is done
    - A lot of call between services.
    - More coupling.

  2. All the services just load the objects they need and monitor periodically the database for any change made to them. My idea was to use the change tracking of sql server 2008 to detect any change made to the objects.

    + Less of traffic and possible communication issues between services.
    + Less coupled
    - Delay due to periodic monitoring.

So, what is your answer on this ? (if you have a 3, 4, etc... It would also be nice)

A: 

In the first option the main service becomes a single point of failure and a performance bottleneck.

In the second you risk a lot of unnecessary polling for information.

A third sugestion would be:

If each of your services has their own database, you could use database replication to move data from the service in which it is created, to the other services in which it is used.

EDIT

Based on your comment. You could try Enterprise Library Caching with a database backing store. That way you have your data in memory, but it will be updated if the values in the database are updated.

Shiraz Bhaiji
Yes ! You have well described the drawbacks of the two methods.Replication won't help in my case, I need notification.In a "ideal" world, my WCF services would subscribe for some database events and will update their business objects accordingly...
Roubachof
Thx for this answer!However Caching Block does the same thing that my solution n°2, in a less smart way.It refreshes periodically all the cache (must compare version of all objects) and raises events accordingly.Mine will periodically poll like the cache block, but will only monitor changed item in the change-tracking table of the desired items.
Roubachof
+1  A: 

Why do you need to synchronize business instances between services? It sounds to me like the services are not loosely coupled enough yet.

Christian Hayter
Problem is some services need to be notified in a certain way in order to know which objects (business instances) have been modified.So I have two solutions. First is a component that notify other services when a business objects is modified. The other is polling for changes in the database thanks to change-tracking.
Roubachof