2

As I understand the payload that is sent to subscribers does not contain any data about the event. Instead I'm supposed to use Microsoft.SharePoint.Client.List.GetChanges and process the changes in a batch. Since my web api server may process multiple events in parallel, how do I make sure that a change isn't processed more than once? As I see it it is possible that two concurrent events will cause two web api controller calls or queue triggered web job functions running in parallel may get the same returned value from GetChanges.

1 Answer 1

1

The answer for implementation is going to vary, but the core mechanism to look at is in the 'ChangeQuery' class. It exposes a 'ChangeTokenStart' and 'ChangeTokenEnd' property. When you prepare to call GetChanges, you will want to pass in a ChangeQuery object with at least the start token set. This will only return changes after your last run. The implication is you will need to store that last run token and account for it in your error handling if the last run fails.

Example: ChangeQuery query = new ChangeQuery(false, false);
query.ChangeTokenStart = lastRunValue;

For further reading: https://www.schaeflein.net/reading-the-sharepoint-change-log-from-csom/

2
  • 1
    Oops - second part to the answer is you could use those tokens to have your processes only pull the latest blocks to work on -not true parallel processing but no repeats. I would look at pushing the changes into a combined queue and then pulling them off to do the parallel processing. The start/end tokens will put a window around the changes being brought back will only be new changes put to the queue and the objects being processed would only come from the queue where each running process is getting a new item when finished with the last.
    – Nick
    Feb 24, 2017 at 16:49
  • Is this what you meant? 1: WebHook adds message to Queue1 2. WebJob1 polls Queue1 with single thread only using stored change token for the list in the message. WebJob1 adds a message for each change to Queue2 and updates the stored change token. 3. WebJob2 processes changes in Queue1 in parallel. So there is no way to do this without the bottleneck in 2? Feb 24, 2017 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.