问题
Where I am right now? I have subscribed to calendar notifications via office365's REST API. When any event in that calendar are created/updated/deleted office365 sends notification to my app's endpoint which I assigned when I created this subscription. Subscription code works like a charm and notifications are coming immediately.
I really want to make my code error tolerant and here comes the problem: what happens if notifications are coming in non-incremental order? For example if someone first creates event and then removes it. Can those notifications come in opposite order? 1. remove event, 2. create event. I failed to find this in documentation.
I am really interested about how you have been handling SequenceNumber
in your code.
This is what documentation says:
SequenceNumber - A number in sequence for a notification, to help the client app identify if it's missing a notification.
Okay, it's nice to know if I missed a notification, but can you tell me what to do in that case? This seems to be really poorly explained in anywhere.
- How
SequenceNumber
behaves e.g. can they come in non-incremental order? - What to do if you miss a
SequenceNumber
?
What I have figured out by testing this, I see that SequenceNumber
is always in incremental order. But I'm not sure is this always the case?
And more importantly, what to do IF my app misses SequenceNumber
? I mean if there comes 1, 2, 3 and next one is 5 or 6, what should I do then?
Also I'm not quite sure if ChangeType: Missed
has something to do with this. I'm really confused about this so any help would be appreciated! :)
回答1:
What I have tested it never jumps over a SequenceNumber, but good practice is to build a notification Queue per subscription and handle notifications one by one ordered by SequenceNumber.
ChangeType: Missed doesn't tell much. Pretty much it tells you only what subscription has missed notification. With calendar integration I ended up to check which calendar corresponds that subscriptionId and then just run full sync to validate if there has any changes in office we missed or not.
来源:https://stackoverflow.com/questions/39320562/what-to-do-if-app-misses-notification-sequencenumber-jumps-over-by-one-or-more