none
when to set the commitKnowledgeAfterThisItem flag RRS feed

  • Question

  • I have written several simple providers all of which appear to work, however the flag in the delete, update and insert routins for commitKnowledgeAfterThisItem confuses me a bit. By its name, I would think that I should set that flag whenever I change the itemmetadata and want that to reflect the "current" version of the item, meaning whenver you return changes in keyandupdatedversion. However the example code both online and in the examples almost never sets this value, even in conditions where the code path indicates it should.  So the question is , when is it appropriate to set this to true ?

     


    Robert G
    Thursday, February 25, 2010 12:55 PM

Answers

  • In the simple sync provider, during change application, the user provider needs to update/delete/create user data and the simple sync provider needs to help update the corresponding metadata. 

    1. If commitKnowledgeAfterThisItem is set to false, it means that the metadata won't update until this batch of user data are updated. 
    2. If commitKnowledgeAfterThisItem is set to true, it means that the metadata will be updated right after every user data change.

    Option 1 can have better performance in general because the metadata are updated all at once for a batch of use data.  But in case there is a factor (such as Internet disconnection) to cause the sync process to fail, then you may get into a situation that some user data are updated but their corresponding metadata are not updated.  So in the next sync you may encounter unnecessary conflicts such as CREATE/CREATE conflicts.

    Option 2 will update metadata after each user data update.  So you may see some performance slowdown when compared to option 1 in the same sync scenario.  But on the other hand, you won't have the problem as described as in option 1.  This is a trade off.  From another angle, if the update of each user data takes a relatively long time compared to the user data, then take this option may not be a bad idea.

    Whether to set commitKnowledgeAfterThisItem depends on your sync environment and scenario.

    Thanks.

    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, February 25, 2010 3:54 PM
    Answerer