A few more words...
Generally, there are two event systems in place with Exchange: Eventsinks that run as COM+ applications on the server, or remote clients, which are notified via UDP packets. Depending on the task you want to accomplish, you should take the one or the other:
- If you must process items in the store synchronously, you must use conventional eventsinks (OnSyncSave and OnSyncDelete).
- If your task is performance critical, you should also use the conventional eventsinks.
- If you are not allowed to run any code on the Exchange server, the only option you have is the WebDAV event system.
The WebDAV event system, has the following drawbacks:
- You are only notified that a change (new item, update or delete) has occured. For example, if you monitor a folder for changes, you will get a notification when a change has occured. You won't, however, get the URL of the changed item. Traditionally, this means that you must du a SEARCH and search for all items with the DAV:getlastmodified property set to a greater value than your last search. With Exchange 2003, new promising system has been introduced, namely WebDAV replication.
- The notification packets are sent via UDP. This means that there are difficulties with firewalls and such things. In this case, you can still use the system, but you must use the POLL method frequently to get information on changed items.
How it works
The chain of action is the following:
The client sends a SUBSCRIBE method to the Exchange server and sets up the subscriptions for the specified folder
The Exchange Server returns a subscription ID to the client that uniquely identifies the subscription.
An item within the monitored folder is modified.
The Exchange server sends an UDP packet to the client which contains a list of all triggered subscription IDs. Until the packet is acknowledged, Exchange will continue sending packets with a decreasing frequency.
After the client has processed the request, it sends a POLL message with the subscription IDs of the events he has handled.
When the client does not need the subscription any longer, it issues an UNSUBSCRIBE call on the folder specifying the subscription IDs he want to cancel.
The example code attached to this article is a console application that monitors a folder or element on an Exchange server for changes. Full source code is included. Note that this example uses the WebDAVLayer component.