locked
[Question] Using Sync with Xml as Metadata RRS feed

  • Question

  • Hi All,

    I'm quite new to Sync and I have a request to use Sync for synchronize two XML files. I know that I can use SqlSyncMetadataStorage for storing metadata, but I want to use XML instead of SQL CE.

    What should I do?

    Thanks,
    -Hieu
    • Moved by Max Wang_1983 Thursday, April 21, 2011 6:05 PM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Monday, October 27, 2008 8:02 AM

Answers

  • You should be able to use files to store your metadata information. Please take a look at the MnagedNTFS sample that is present in the SDK and see if helps you give a start.

    Wednesday, October 29, 2008 6:58 AM
  • To answer your questions....

     

    "- Data Source for source and dest are different. For example, one is XML, and one is Database. So do I need to write two Knowledge class for each datasource?

    - Metadata must not use SQL database for storage. Do I need to have two metadata class?"

     

    You don't need to implement the knowledge, that's something we provide.  You will need to implement a metadata store as a place to store the knowledge and item metadata (update versions for each item).  Depending on how you want to do this, you may only need to write this once and use it in both providers.  You can implement this however you want, since it's being used from within your provider.  You just need to serialize the knowledge into it, and you should be fine.  I would mention though, that since one side is a database, you may be better off putting the metadata in a side table in the database.  This will allow you to keep the metadata alongside the actual data.  Also, if your database has features like change tracking, you may gain some optimized performance during change detection.

     

    "- How do I handle conflict in my sync application for source and dest?"

    If you use the notifying change applier, the Sync Framework handles detecting conflicts for you.  It allows you to either specify a simple policy at the beginning (source wins or destination wins), or register for a callback when conflicts occur.  You can then do what you want in this callback (merge data, allow the user to pick winner through UI, etc.)

     

    In general, the best place to learn about the flow of synchronization is at http://msdn.microsoft.com/en-us/sync/bb821992.aspx.  Look under the "Synchronization Flow" section, though I'd recommend reading the entire page.

     

    Aaron

     

     

    Thursday, October 30, 2008 4:26 PM

All replies

  • You should be able to use files to store your metadata information. Please take a look at the MnagedNTFS sample that is present in the SDK and see if helps you give a start.

    Wednesday, October 29, 2008 6:58 AM
  • Mahesh,

     

    I find that the FeedSync sample is useful.

    http://www.codeplex.com/feedsyncsamples/

    http://dev.live.com/feedsync/

     

    It does generate the Data Store into Xml Metadata Source as my needs

     

    Thanks,

    -Hieu

    Wednesday, October 29, 2008 3:28 PM
  • Hi Hieu,

     

    You should note that, depending on the type of data your are trying to sync, using FeedSync to store your metadata may introduce some inefficiencies.  This is because FeedSync projects the replica-level metadata (the knowledge) onto each item.  This introduces a large number of single item exceptions, which reduces the efficiency of knowledge operations.  You could potentially use FeedSync to store the last update versions and retain efficiency if you stored the replica metadata somewhere else in the feed.  I haven't tested this scenario to guarantee that it would just work.  You'd also have to do the work to put knowledge in feed.

     

    Another place you may want to look is at the FeedSync Producer Consumer Favorites Sample (http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=849).  This is used to produce FeedSync feeds, but the source Favorites provider stores its metadata in XML apart from that.  I can't guarantee that this is teh best implementation of this approach, but it may be a start on showing you the things you'd have to do to enable the scenario.

     

    Aaron

     

    Wednesday, October 29, 2008 8:01 PM
  • Hi All,

     

    I have looked at both ManagedNTFS and FeedSync, seem that it does not cover my requirement but the Xml metadata store.

    BTW, here is my requirement for syncing

    - Data Source for source and dest are different. For example, one is XML, and one is Database. So do I need to write two Knowledge class for each datasource?

    - Metadata must not use SQL database for storage. Do I need to have two metadata class?

    - How do I handle conflict in my sync application for source and dest?

     

    And I also want to know more about the workflow of Sync Framework, where can I have this?

     

    Many thanks,

    -Hieu

    Thursday, October 30, 2008 3:05 AM
  • To answer your questions....

     

    "- Data Source for source and dest are different. For example, one is XML, and one is Database. So do I need to write two Knowledge class for each datasource?

    - Metadata must not use SQL database for storage. Do I need to have two metadata class?"

     

    You don't need to implement the knowledge, that's something we provide.  You will need to implement a metadata store as a place to store the knowledge and item metadata (update versions for each item).  Depending on how you want to do this, you may only need to write this once and use it in both providers.  You can implement this however you want, since it's being used from within your provider.  You just need to serialize the knowledge into it, and you should be fine.  I would mention though, that since one side is a database, you may be better off putting the metadata in a side table in the database.  This will allow you to keep the metadata alongside the actual data.  Also, if your database has features like change tracking, you may gain some optimized performance during change detection.

     

    "- How do I handle conflict in my sync application for source and dest?"

    If you use the notifying change applier, the Sync Framework handles detecting conflicts for you.  It allows you to either specify a simple policy at the beginning (source wins or destination wins), or register for a callback when conflicts occur.  You can then do what you want in this callback (merge data, allow the user to pick winner through UI, etc.)

     

    In general, the best place to learn about the flow of synchronization is at http://msdn.microsoft.com/en-us/sync/bb821992.aspx.  Look under the "Synchronization Flow" section, though I'd recommend reading the entire page.

     

    Aaron

     

     

    Thursday, October 30, 2008 4:26 PM
  • Aaron,

     

    Thanks for your answer, it's really helpful to me.

    One more question, it's about conflict detection. Can I customize conflict detection engine? If yes, how can I do that? Which interface to override and which event to handle?

     

    Thanks,

    -Hieu

     

    Saturday, November 1, 2008 11:44 AM
  • You can customize conflict detection by implementing your own change applier.  This allows you to determine conflicts however you choose.  However, if you are new to sync, I wouldn't recommend that.  You likely want to customize the conflict resolution

     

    In native code, you would do this by implementing the ISyncCallback interface and putting your conflict resolution in the OnConflict method.  You would then pass your implementation to the RegisterCallback method on the ISyncSession interface.

     

    In managed code, you want to implement an ItemConflicting event handler.  You would then specify this on the DestinationCallbacks for your destination handler.  You can look here (http://msdn.microsoft.com/en-us/library/microsoft.synchronization.synccallbacks.itemconflicting.aspx) for more information.

     

    Aaron

    Sunday, November 2, 2008 9:18 AM
  • Thanks, I'll try and get back soon.

     

    Monday, November 3, 2008 4:16 AM