ews-managed-api icon indicating copy to clipboard operation
ews-managed-api copied to clipboard

SyncFolderItems Sync State Max Size - EWS Managed API

Open anilreddyr7 opened this issue 6 years ago • 2 comments

We are trying to use SyncFolderItems EWS operation. The request is below.

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> soap:Header <t:RequestServerVersion Version="Exchange2013" /> </soap:Header> soap:Body <m:SyncFolderItems> <m:ItemShape> <t:BaseShape>IdOnly</t:BaseShape> </m:ItemShape> <m:SyncFolderId> <t:DistinguishedFolderId Id="inbox" /> </m:SyncFolderId> <m:MaxChangesReturned>10</m:MaxChangesReturned> <m:SyncScope>NormalItems</m:SyncScope> </m:SyncFolderItems> </soap:Body> </soap:Envelope>

Response:

<m:SyncFolderItemsResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <m:ResponseMessages> <m:SyncFolderItemsResponseMessage ResponseClass="Success"> <m:ResponseCode>NoError</m:ResponseCode> <m:SyncState>H4sIAAA==</m:SyncState> <m:IncludesLastItemInRange>true</m:IncludesLastItemInRange> <m:Changes> <t:Create> <t:Message> <t:ItemId Id="q04QAAAA==" ChangeKey="CQAAABYAAABhFfgM7MNwSYx0VZ0GoBMJAAAATVdC"/> </t:Message> </t:Create> <t:Create> ------------it has more

The sync state value is growing bigger after each sync folder items request. We have observed it occupies 10 pages. It is not finite in length. What is the maximum size of the sync state and how you are handling sync state field on your side?

anilreddyr7 avatar Jan 04 '19 07:01 anilreddyr7

I didn't find any information about size of SyncState field when I was interested in this question. The one of drawback with SyncFolderItems method is the fact that the synchronization state can become quite big. In my case:

Number of items SyncState (in bytes)
512 1804
1024 2464
1536 3040
2048 3504

pkropachev avatar Jan 05 '19 21:01 pkropachev

The size can grow, but when you get to the end of the current set of changes the size should collapse. There are pathological cases which can cause the sync state to become very large, but typically it's not too bad. Outlook Desktop has to upload the entire sync state every time you receive a new mail. So it won't grow forever.

there is no concept of resetting the sync state. You can start over, but after you sync the state should be the same. It's a reflection of the items in the folder. The more items in the folder the larger the state "can" get. Since the state stores sets of ID or CN values in a perfect world the sync state should be small if all IDs or CNs are contiguous. It can get large if there are lots of holes in the sets.

davster avatar Jan 05 '19 22:01 davster