locked
Peer to Peer Synchronization using Sync Framework RRS feed

  • Question

  • Here is the scenario that I would like to build:

     

    1. I start up my WPF desktop application (built in VS 2008 of course). This app is storing it's data in a local XML file (or whatever, I gather the format of local persistence is irrelevant).

     

    2. I continue to work locally in my application.

     

    3. Another instance of my application is fired up somewhere else on the LAN. The two instances of the application now synchronize data so that info entered in App B since it was last online is copied to App A, and vise versa.

     

    I don't care about synchronizing with a SQL server, in fact, it is a requirement that my scenario is serverless. This is a purely peer to peer situation. I have a lot of experience writing WCF code in P2P channels, so I _almost_ wrote my own code to do this when I found the Sync Framework.

     

    Basically what I'm looking for is an API that says "here's my data, sync it over net.p2p://myapp/synchchannel"

     

    Is this something that Sync Framework can do for me? If so, is this out of the box or do I have to write my own provider that uses the WCF peer channel?

    Friday, December 28, 2007 1:52 PM

Answers

  • Well, I would agree with you if there is one designated client is publishing changes and the rest of the clients in the peer network just consume it. However, what I understand is that every client will publish its own changes and other peers will then consume it ..etc. If this is the case, then it will get tricky quickly and it appears to me that the sync framework is one way to address the complexity.

     

    The complexity I am referring to could manifest itself in a scenario like this: P1 publishes its changes, P2, P3 consumed P1's changes. Now, P2 made changes on top of what P1 changes. P3 did the same thing. Now consider the following cases:

    1- When P1 consumes the changes from P2 and P3, will you detect conflicts?

    2- What if P4 consumes P3 changes first, then it goes to consume P1 changes second, will you overwrite more recent content with older one?

     

    Is this kind of data flow is not expected in your scenario?

     

    Thanks

     

    Friday, December 28, 2007 9:48 PM

All replies

  • Hi Kevin,

     

    Yes, you can use the Sync Framework to build this scenario.

     

    You would have to write your own provider though. The current providers we have out of the box are for files and for databases. The framework does not define the transport; that said you will need to write some serialization code to move data and metadata across the peer channel.

     

    My suggestion would be to start with existing providers. Let's say you can use the File Provider to sync files. Assuming that each item will be stored in separate xml file. With that, all you need to do is to write the transport code. Check this thread for more details.

     

    Thanks

    Friday, December 28, 2007 6:35 PM
  • I'm thinking that the MSF might be overkill for what I'm doing. I have relatively small concern for the actual resolution of conflict changes, since in my particular domain that's really easy stuff. My scenario basically involves a client application telling the entire WCF peerchannel mesh "here's a delta, enjoy". All the other client applications on that channel then absorb the delta and go on their merry way.

     

    I'm thinking that bending the MSF to this model might take more effort than just writing a quick WCF library that handles this scenario.

    Friday, December 28, 2007 7:08 PM
  • Well, I would agree with you if there is one designated client is publishing changes and the rest of the clients in the peer network just consume it. However, what I understand is that every client will publish its own changes and other peers will then consume it ..etc. If this is the case, then it will get tricky quickly and it appears to me that the sync framework is one way to address the complexity.

     

    The complexity I am referring to could manifest itself in a scenario like this: P1 publishes its changes, P2, P3 consumed P1's changes. Now, P2 made changes on top of what P1 changes. P3 did the same thing. Now consider the following cases:

    1- When P1 consumes the changes from P2 and P3, will you detect conflicts?

    2- What if P4 consumes P3 changes first, then it goes to consume P1 changes second, will you overwrite more recent content with older one?

     

    Is this kind of data flow is not expected in your scenario?

     

    Thanks

     

    Friday, December 28, 2007 9:48 PM