Sunday, December 03, 2006

CAB, EventBroker, and Wildcards

I will be blogging about the CAB EventBroker soon. But, I think that I like mine (previously published here) better. I would like to see wildcard support in the EventBroker's subscription strings.

In CAB, you can define an event to be published like this:

[EventPublication("event://Trade/Update", PublicationScope.Global)]
public event EventHandler TradeUpdated;

........

public void TradeIsUpdated(Trade trade)
{
if (this.TradeUpdated != null)
{
this.TradeUpdated(this, new InstrumentUpdatedEventArgs(trade));
}
}

In some other module, you can subscribe to an event like this:

[EventSubscription("event://Trade/Update")
public void OnTradeUpdated(object sender, InstrumentUpdatedEventArgs e)
{
}

I need wildcards. I might like to have a function that gets called when any operation happens to a Trade object. So, I would like to see subscription topics like these:

"event://Trade/*"

or

"event://Trade

Both of these would cover the case when any operation happens to a trade. The subscription string would catch the following topic:

event://Trade/Updated
event://Trade/Deleted
event://Trade/Created

I need Tibco-lite as my internal message bus.

©2006 Marc Adler - All Rights Reserved

4 comments:

Anonymous said...

Wildcards alone can be convenient but limiting. You might want to implement a special kind of subscription that returns all the event types associated with a trade and then iteratively subscribe to each. This allows the subscriptions to goto different places (or even be load balanced etc.) if the different event types come from different sources.

Just my $0.02 tho - not a CAB or C# expert :-)

-craig

terry said...

is CAB open enough to let you extend event subscriptions yourself?

Anonymous said...

CAB ships with the source code so you can do what you want to amend the code (caveit emptor for future changes) or you can publish an event since you don't have to use the attributes you could simply build a utility function to iterate through all subscriptions of the current workitem and multicast to those subscribers using whatever wildcard paradigm you want using programmatic control instead of the attributes.

while (somecondition == true)
{
workitem.EventTopics.Get("\event1\foo").Fire(sender, workitem, PublicationScope.WorkItem);

}

-Christian Thilmany - Architect, Microsoft Corp.

Stuff It said...

> But, I think that I like mine (previously published here)
Can you add a link to your previously published post? I can't find it from searching your blog