OfficeDev / ews-managed-api

Other
585 stars 319 forks source link

Add public constructor to StreamingSubscription for continuing an existing subscription #130

Closed poizan42 closed 6 years ago

poizan42 commented 7 years ago

The use case is if you have a service that is listening for changes to potentially tens of thousands of mailboxes then it can take a long time to create all the subscriptions (several hours!). So caching those subscription ids can substantially speed up the restart of the service enormously (at least as long as they are still valid). However to do that we need to be able to create subscription objects representing those existing subscriptions.

poizan42 commented 7 years ago

I don't know if some remark should be added about no verification being done (it will of course fail later on GetStreamingEventsRequest.InternalExecute() if it's invalid). But the lack of verification against the server is exactly the point to speed things up.

There is also some good question about how long the subscriptions are valid, which I can't find any documentation on.

davster commented 7 years ago

The subscription itself will live as long as it is able (sans process restarts, disconnected Exchange store MAPI connections, etc...). In contrast, the streaming connection you open specifies a timeout as it is a hanging GET. When a subscription dies for some reason and you try to perform work against it, EWS will just return invalid subscription and you will resubscribe.

poizan42 commented 7 years ago

@davster Are we waiting for the cla bot? I tried sending a mail to azclasa@microsoft.com - it bounced with :

Diagnostic information for administrators:

Generating server: BN6PR21MB0627.namprd21.prod.outlook.com azclasa@microsoft.com Remote Server returned '554 5.2.2 mailbox full; STOREDRV.Deliver.Exception:QuotaExceededException.MapiExceptionShutoffQuotaExceeded; Failed to process message due to a permanent exception with message Cannot get ID from name. 16.55847:84060000, 17.43559:000000008C000000000000000000000000000000, 20.52176:140F0D800000000000000000, 20.50032:140F0D807017000000000000, 0.35180:140F0D80, 255.23226:80030400, 255.27962:56000000, 255.17082:B9040000, 0.16993:DD040000, 4.21921:B9040000, 255.31418:DD040000, 0.22753:FA000000, 255.21817:B9040000, 0.37224:00000000, 4.40808:DD040000, 0.24529:362D3462, 4.18385:DD040000, 0.36864:66653661, 4.37120:DD040000 [Stage: CreateMessage]'