When I register an ItemEventReceiver to a List in a SharePoint farm, when & where will it get instantiated, and when & where will its event-handling-methods be called?
The options I could imagine:
- Instantiated ONCE on ONE server in the Farm
- Instantiated ONCE on EVERY server in the Farm
- Instantiated MULTIPLE TIMES on EVERY server in the Farm
- Instantiated ONCE for EVERY active item, then garbage collected after item is inactive for some time (so if an eventreceiver instance for an item gets created on one server, there will be no more instances be created on any server, until this event receiver gets garbage collected)
If options 2 or 3 are the case, can events for the same item be fired on different instances? Or will events for the same item always fire in the same instance? For example: there is one event receiver instance on server 1, and 2 instances on server 2. Now item X gets updated 2 times in a row. Is it guaranteed that always the same of those 3 instances handles the event?
UPDATE
As I don't get the answers I need, I'll provide some background why I need this information:
I'm developing a software that listens on every file upload or change. When the event fires, an external software gets notified via a HTTP request. The software then modifies the file and uploads it back to sharepoint. To do so, it checks it out, adds some fields to the file, updates the content and then checks it back in. Those operations trigger the SPItemUpdated event again multiple times.
But of course, for those events, I don't want to notify the external software again. The EventReceiver needs to keep track of when the external software starts modifying the file and when it's done and ignore events in between for the specific files.
To find a good strategy for this, it is very important to know the lifetime of an eventreceiver object. For example, if the eventreceiver only runs once, I can keep track of the state of the files in memory. Instead, if the eventreceiver gets called multiple times, every eventreceiver will have it's own states and it would not work. Except there is some guarantee that a file is never processed by different instances, then it would not matter.
I hope you understand now, that is indeed important to know the lifetime of an instance.