1

I'm working on integrated an application with Exchange using EWS Java. Yes, it's not officially supported, I know. It's all pretty straightforward and I have streaming notifications set up with the exchange server. However, I've hit a couple of snags that are a bit head-scratching.

First, it seems that every event (or batch of events) gets sent twice. For example, if I'm watching the Calendar for Modified events and I create a new appointment or modify an appointment, I'll get two identical notifications, each with an ItemEvent and a FolderEvent. They're definitely distinct objects coming in one right after the other and there is zero difference between the two events. Each object has the same value in any relevant field as the previous. The only difference seems to be the memory address.

Second, I'm hoping to make the notifications a bit more fine-grained. I want to see when a calendar item has been modified, but not when a calendar item is created. It appears that I can only watch the Calendar folder overall and that Modified includes new items. Is there any way to make that more precise?

EDIT: Actually, I found that this only seems to happen with Meetings created in the Calendar folder, and only those with other Attendees. Two NotificationEventArgs, each with a FolderEvent and an ItemEvent. On further inspection, I recently found that one ItemEvent is Created and one is Modified, which isn't terribly surprising to me now knowing how Exchange tends to handle Appointments. The idea was to watch for both created and modified items, although I suppose it could have been broken up into two streaming subscriptions or, given the behavior, set to only modified as that would have captured "new" Appointments anyway.

In any case, this was handled with a periodic SyncFolder (Much was changed between the asking of this and the final design), which worked out well in the end.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
user1017413
  • 2,023
  • 4
  • 26
  • 41

1 Answers1

2

Although I dont have experience of working on EWS in Java, Ill try to answer your questions as the concept remains the same. My code references will be from C#

For the first part, the behavior you are experiencing is the expected behavior. When you subscribe to a folder, you get notified on any event that you have specified while creating the subscription takes place. Thus if you have subscribed to the "Calendar" folder for Modified and Create events, and you create or modify an appointment, you will get 2 notifications:


1 for the Folder level changes (FolderEvent): even if you create a new item, the folder has actually been "modified"
1 for the Item level changes (ItemEvent): for the created item

These two are NOT same. They may look similar as both inherit from "NotificationEvent" base class, but are different types. http://msdn.microsoft.com/en-us/library/office/microsoft.exchange.webservices.data.folderevent(v=exchg.80).aspx http://msdn.microsoft.com/en-us/library/office/microsoft.exchange.webservices.data.itemevent(v=exchg.80).aspx

For the second part, to see only modified events, select only "EventType.Modified" when you are creating the subscription. It would be good if you can share your code snippet to show how you are subscribing.

Andy
  • 1,080
  • 5
  • 20
  • 35