Event Filtering

If you would like to alter the default publish/subscribe behavior, COM+ provides a mechanism called event filtering. There are two kinds of filtering. The first, publisher filtering, lets you change the way events are published and therefore affect all the subscribers for an event class. The second, subscriber filtering, affects only the subscriber using that filter.

Both kinds of filters usually let you filter events without changing the publisher or the subscriber code. However, I find that event filtering is either cumbersome to use and implement, or limited and incomplete in what it offers. Those shortcomings are mitigated by the use of the COM+ Catalog wrapper object.

Publisher Filtering

Publisher filtering is a powerful mechanism that gives the publisher fine-grained control over event delivery. You can use a filter to publish to only certain subscribers, control the order in which subscribers get an event, and find out which subscribers did not get an event or had encountered an error processing it. The publisher-side filter intercepts the call the publisher makes to the event class, applies filtering logic on the call, and performs the actual publishing (see Figure 9-8).

A publisher filter

Figure 9-8.  A publisher filter

If you associate a filter with an event class, all events published using that class go through the filter first. You are responsible for implementing the filter ...

Get COM & .NET Component Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.