Exchange Streaming Notifications and Synchronization RRS feed

  • Question

  • Hi,

    I am building what will be a Windows service application using the EWS Streaming Notifications capability available in Exchange 2010 SP1.  I started with the example application discussed in the MSDN article entitled 'Using Streaming Notifications with Exchange 2010'.

    I am only interested in new mail events in a single inbox.  I have the OnNotificationEvent trigger successfully processing new mail events.  I also have a background thread running that does a SyncFolderItems every 10 minutes.  I am not exactly clear how the synchronization plays in all this, but the desire is guaranteed one-time processing of all new mail events.  Therefore I am hoping the synchronization will provide “recovery” of events in case the service or other dependent resources are temporarily down.

    My sync code is as follows:

       Public Sub SynchronizeChanges(folderId As FolderId)

            Dim moreChangesAvailable As Boolean


                LogWriter.WriteLine("Synchronizing changes...")

                ' Get all changes since the last call. The synchronization cookie is stored in the _SynchronizationState field.

                ' Only the the ids are requested. Additional properties should be fetched via GetItem calls.

                Dim changes = _ExchangeService.SyncFolderItems(folderId, PropertySet.IdOnly, Nothing, 512, SyncFolderItemsScope.NormalItems, _SynchronizationState)

                ' Update the synchronization cookie

                _SynchronizationState = changes.SyncState


                ' Process all changes

                'For Each itemChange In changes

                ' This example just prints the ChangeType and ItemId to the console

                ' LOB application would apply business rules to each item.

                'LogWriter.WriteLine("ChangeType = " & itemChange.ChangeType)

                'LogWriter.WriteLine("ChangeType = " & itemChange.ItemId.ToString)


                ' If more changes are available, issue additional SyncFolderItems requests.

                moreChangesAvailable = changes.MoreChangesAvailable

            Loop While moreChangesAvailable

        End Sub

    My question is about the commented out code at the bottom of the above sub.  If the service or Exchange were unavailable for a period of time, is the For Each loop required to process new mail because the OnNotificationEvent would not have fired?  If yes, then I will obviously need to adjust the For Each loop to suit my needs.

    Also interested in feedback about whether or not this is a design that should provide guaranteed one-time processing of incoming mail.  I do not expect this inbox to get much traffic but processing and responding is important.

    Friday, July 26, 2013 9:21 PM