|
To set up the subscription for events from a custom service, CallExternalEventActivity registers with the CorrelationService, and calls the specified method on the custom service to create the event subscription.
When an event is raised by the custom service, it is handled by the HandleExternalEventActivity. When this activity is unsubscribed, it cleans up its own subscription with the CorrelationService, but it provides no means for the subscription with the custom service to be cleaned up, as there are no overridable unsubscribe method.
This means that subscriptions cannot be manually removed from custom services!
I appreciate that for once only guaranteed events, such as the CorrelatedLocalService sample this isn't a problem as the subscription cleans itself up when done, but for other things such as a file watcher service or message queue listener service, where the events are neither once only nor guaranteed, the subscriptions cannot necessarily clean themselves up (for example, the specified file system event may never be raised).
Now either I'm missing something (entirely possible) or this is a serious design flaw in the HandleExternalEventActivity activity. It looks as though it could be easily solved by declaring the private UnsubscribeForActivity as "protected virtual" but at the moment it is a major issue.
Any comments appreciated.
(note that at the moment, I have wrapped the HandleExternalEventActivity inside a SequenceActivity, implemented the IEventHandler and IActivityEventListener<QueueEventArgs> interfaces which pass through to the handler activities implementations, and added my custom unsubscribe code to the Unsubscribe and Execute methods. This also required me to write a custom CorrelationTokenType converter as the provided one is internal, so it hardly seems an ideal solution although it does appear to work fine) |