.NET publish/subscribe support

  • Thread starter Thread starter Russ Goetz via .NET 247
  • Start date Start date
R

Russ Goetz via .NET 247

Can anyone tell me if .NET directly supports the publish/subscribe messaging paradigm. If not directly, are there add-ons available that will provide this type of functionality?

Thanks in advance,
Russ
 
Russ said:
Can anyone tell me if .NET directly supports the publish/subscribe
messaging paradigm. If not directly, are there add-ons available that will
provide this type of functionality?

Thanks in advance,
Russ
I think that there events/delegates cleanly implements the publish/subscribe
pattern.
 
Russ said:
Can anyone tell me if .NET directly supports the publish/subscribe
messaging paradigm. If not directly, are there add-ons available that
will provide this type of functionality?

Depends exactly what you want. .NET delegates are managed 'function
pointers' so you are free to pass them between objects even between
processes. The delegate class maintains an internal linked list, so you can
combine together delegates to form a chain so that when the container
delegate is invoked, all the delegates in the list are invoked. .NET events
are a metadata device to indicate that a class will raise events of a
particular delegate type, as well as providing a standard mechanism to add a
new delegate to the event's delegate. The problem with delegate/events is
that they are tightly coupled, that is the code that handles the event lives
at least as long as the code that raises the event, and to create a
'subscription' the code that raises events must be running. Since delegates
are serialisable you can do tricks like serializing them to some persistent
store, which gets over this tight coupling, but its not a supported
mechanism.

If you want loose coupling, ie you can create a subscription with neither
the publisher nor the subscriber executing, and when you raise an event the
subscribers will be instantiated, then you should use .NET component
services (COM+) events. This is a .NET wrapper around COM+ events which
still works fine. It also has the ability to raise an event to all
subscribers in parallel, getting round an irritiating issue of delegates
where if one handler throws an exception the entire invocation is aborted
(you can fix this, but it would have been nice for the .NET designers to
have thought about this issue).

Richard
 
Back
Top