locked
sync data: 1 server and N clients RRS feed

  • Question

  • Hi, guys.

    First, good job with MS Sync Frmw!

    Well... I have a big problem (for me).
    I need synchronize 1 server (SQL Server 2008) with multiple clients (SQL Server 2008 Express) in bidirecional direction.

    I'm newbie with synchronization. That's my first experience. So, I ask for a big help for my big problem.
    Samples are very appreciated.

    Please, help me. Thank you very much.
    Theo Fernandes
    • Moved by Max Wang_1983 Wednesday, April 20, 2011 11:30 PM Forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Monday, October 19, 2009 10:41 PM

Answers

All replies

  • Hi -

    We just released the Microsoft Sync Framework V2.0 - you should download that along with the SDK and take a look at the samples that are available. That should help you get started.
    http://www.microsoft.com/downloads/details.aspx?FamilyID=89adbb1e-53ff-41b5-ba17-8e43a2e66254&displaylang=en

    Thanks
    Deepa
    Deepa ( Microsoft Sync Framework)
    Tuesday, October 20, 2009 4:57 PM
    Answerer
  • Hi, Deepa.
    Thanks for your reply.

    Well, I had seeing the examples, but I could not move into the problem.
    Using Local Database Cache in Visual Studio, I can do it easily. But it's not my scene (p2p) and I can't do it manually.
    I'm creating my own application to synchronize my databases, but it's sux alot.

    I will continue trying to MSF, but it is difficult at the moment for me.
    I know it's boring for everyone to create step-by-step to teach, but I'm completely lost.

    Thank you very much.

    Theo Fernandes
    Tuesday, October 20, 2009 8:12 PM
  • Hi Theo!

    A few weeks ago I have been in a very similar situation. It took me quite a while to get into MSF but believe me: It is worth the time! Most MSF samples show P2P sync or treat a client/server scenario very similar to a P2P sync system.

    Here are some hints that could maybe help you:

    1. Take a look at ADO.NET Sync Services. Although you may not use it directly it will give a much clearer picture about how you can implement a server/client sync.
    2. MSF's sync knowlege is extremely powerful, too powerful for client/server sync. In your case you just need to store the following pieces of information:
       a) On the server: Creation version and last update version per row
       b) On clients: Creation version and last update version per row, last received server version (=last received anchor), last sent client version (last sent anchor)
       With this you can create the server's and the client's knowledge every time the sync provider starts:
       Client:
    // Get the knowledge about the client store
    this.knowledge = new SyncKnowledge(
    	this.IdFormats,
    	new SyncId(clientStore.ReplicaId),
    	this.currentClientTimestamp = this.clientStore.Clock.CurrentLogicalTimeStamp);
    // What does the client know about the server? Answer: The LRA 
    var knowledgeAboutServer = new SyncKnowledge(this.IdFormats, new SyncId(clientStore.ServerReplicaId), clientStore.LastReceivedAnchor);
    // Combine both to get the current knowledge of the server
    this.knowledge.Combine(knowledgeAboutServer);
       Server:
    // Get the knowledge about the server clientStore
    this.knowledge = new SyncKnowledge(
    	this.IdFormats,
    	new SyncId(serverStore.ReplicaId),
    	this.currentServerTimestamp = serverStore.Clock.CurrentLogicalTimeStamp);
    // What does the server know about the client? Answer: The LSA of the client
    var knowledgeAboutClient = new SyncKnowledge(this.IdFormats, new SyncId(clientStore.ReplicaId), clientStore.LastSentAnchor);
    // Combine both to get the current knowledge of the server
    this.knowledge.Combine(knowledgeAboutClient);
    3. You need to store deletes separately in both data stores (server & client)
    4. On the server you can use SQL Server's change tracking. However, we decided not to use it because one database became corrupted and could not be backed up any more because of change tracking. I never want to get into such a situation on production systems. Therefore we implemented our own logical clock in a helper table.

    I hope this helps.

    Kind regards,
    Rainer.

    Rainer
    Wednesday, October 21, 2009 11:22 AM