locked
RelationalSyncProvider – Not getting conflict event when using WCF RRS feed

  • Question

  • Hi there

    I’m new to SyncFX and got stuck with the problem of not getting any conflict events (ApplyChangeFailed) when I update my Sql Compact to Sql Express database or vice versa. The final aim of my project is to use WCF to communicate with the remote SQL Express database. I give a short overview what I did and what sources I use. Please bear with me or jump ahead to the WCF implementation question of the SqlSyncProvider that might causes the problem (skip the next 2 paragraphs).

    What I did to begin with: I started small and just used a local SQL Express 2008 with change tracking activate. My application created a new SQL compact 3.5 database file and I synchronized it by setting up a Scope on each database and used a SqlCeSyncProvider/SqlSyncProvider for the SyncOrchestrator. Then I added the listener for the ApplyChangeFailed events of the provider to resolve any conflicts. At that point I was really amazed how easy it was. Great job Sync Team!!

    However, now to the last part. I just wanted to adjust the local SqlSyncProvider that I can run it on a server side and use a proxy on the client utilizing WCF. As guidance I used the excellent example of LarenC  Database Sync - Peer-to-Peer over WCF ” (http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=3423 ). After some time studying the code I extracted his SqlWebSyncService and SqlSyncProviderProxy, including all sub classes and interfaces. Alter that I used the SqlSyncProviderProxy class instead of SqlSyncProvider in my previous example and it worked fine. Could synchronize changes in both directions, great! At this point I removed the listener for the conflict events. After I tested some conflict scenarios, I noticed that always the server wins. OK, then I listened to the conflict event ApplyChangeFailed but now the problem starts. The SqlSyncProviderProxy class derivates from KnowledgeSyncProvider that does not define the event. I changed the derivative to RelationalSyncProvider but still the event is never fired. Then I had a deeper look into the code and found the following that might be the problem:

     

    The SqlWebSyncService derivates from RelationalWebSyncService which defines BeginSession and ApplyChanges. BeginSession usualy has two parameters but the WCF Contract defines it only with the first one, because the second one (SyncSessionContext ) isn’t serializable. Could that be the reason I do not get the ApplyChangeFailed event?

    I also tried to create the SyncSessionContext class at the server side with an instance of SyncCallbacks that listens on ApplyChangeFailed before I call BeginSession of the SqlSyncProvider instance at the server. You guessed it, it does not work.

    I also checked the ApplyChanges method that when calling ProcessChangeBatch the ConflictResolutionPolicy is set to ApplicationDefined and I also passed over the initiated SyncCallbacks instance from before. However, no ApplyChangeFailed event is fired when I create a conflict.

     

    Thank you for any hints in the right direction. I’m getting nuts here and want to throw my PC out of the window. And sorry for any stupid terminology as I use SuncFX only for 3 days and WFC for 2 weeks.

     

    Cheers

    Thorsten

    Wednesday, June 9, 2010 6:23 PM

Answers

  • All solved!

    Sorry guys, stupid 4am  error.  Why use SyncCallbacks when you just should listen to the ApplyChangeFailedof the server side RelationalSyncProvider.

    A freesh start in the morning always helps :)

    Thursday, June 10, 2010 6:24 AM

All replies

  • All solved!

    Sorry guys, stupid 4am  error.  Why use SyncCallbacks when you just should listen to the ApplyChangeFailedof the server side RelationalSyncProvider.

    A freesh start in the morning always helps :)

    Thursday, June 10, 2010 6:24 AM
  • Hi Thorsten,

    Can I contact you to exchange some thoughts about conflict handling when using WCF?

    Monday, July 5, 2010 10:49 PM