Click here to Skip to main content
Click here to Skip to main content

Message & InfoBus Components

, 9 Dec 2002
Rate this:
Please Sign up or sign in to vote.
An article on message/info bus components for lightweight messaging.

Sample Image - message_infobus.gif

Introduction

This is a group of components that can easily be added to any application needed some kind of lightweight messaging framework.  Much simpler than the MessageQueue class, these components themselves are completely integratable with Visual Studio.NET, as you can see from the above image of the test client using the SingletonMessageBus component. NOTE: this project is dependent on NUnit to build (see the nunit site) but hey, we all unit test, so you've already got this installed, right? Smile | :)

Background

I was developing a rich client that needed to consume a web service.  This was an MDI based application, for the most part in which I was using a model-view-controller (MVC) design in the window implementations.  I noticed, however, that when you had a situation with multiple potential models, the MVC paradigm became somewhat burdensome.

To solve this problem, I created the two messaging systems included in this DLL.  In most cases, unless you find yourself in a situation where you need multiple busses of the same type in your application, the SingletonMessageBus and SingletonBuilder give you an easy and fast way to implement this kind of messaging.

I wanted to avoid using the MessageQueue class because it was just too heavyweight for what I needed.

Using the code

The controls are pretty straightforward to use.  Just build the project, and add the resulting DLL to the toolbox, and the components should appear as shown in the first image in this article.

The SingletonMessageBus is very easy to use as it supports a single event, really, only a single method of interest.  For example, the above image shows a child form from the test project which aggregates a SingletonMessageBus component.  Double-clicking on the component will create a handler for the default event, which would look something like this:

private void singletonMessageBus1_Message(object sender,
    OsoGrande.Notification.Message.MessageEventArgs e)
{
    // You can catch your own messages if needed, as well as messages
    // from others.
    if ( sender == this )
        MessageBox.Show( "Caught my message." );
}

The handler, of course, is automatically added to the Message event by the Visual Studio.NET IDE:

// 
// singletonMessageBus1
// 
this.singletonMessageBus1.Message += 
    new OsoGrande.Notification.Message.MessageHandler(this.singletonMessageBus1_Message);

Submitting messages is equally easy via the SubmitMessage() method:

this.singletonMessageBus1.SubmitMessage( this, 
    new MessageEventArgs(null, this.isEnabled ) );

That's it! The message is delivered to all registered listeners.  The InfoBus component is more complex in that the protocol is a bit more convoluted, but it acts in roughly the same way.  Specifically, the InfoBus itself is aggregated into the Builder, which adds and removes data consumers and producers from the bus. Consumers are notified of the existence of data, indicate interest (if any), are delivered the data, and can then choose to opt out of future notifications from that specific producer if deemed appropriate.

The components are fully integrated and the classes implementing these components are contained in a separate support DLL and aggregated via the Bridge pattern to the classes implementing any component-specific features.

Points of Interest

This was a good exercise in component development, in that in the InfoBus communication that traditionally was modeled as method calls I converted to events to support higher ease of integration with Visual Studio.NET.

Update History

  • 12/03/2002 - Initial Submission
  • 12/10/2002 - documented a dependancy

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

lambo82669
Web Developer
United States United States
No Biography provided

Comments and Discussions

 
GeneralWaste of time Pinmembersytelus28-Jan-03 18:01 
GeneralRe: Waste of time PinsussAnonymous20-May-04 15:48 
GeneralNUnit Dependency Infomation Pinmemberlambo826695-Dec-02 5:42 
QuestionMissing? PinmemberRocky Moore5-Dec-02 0:28 
GeneralThis looks to be very useful PinmemberMarc Clifton4-Dec-02 11:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 10 Dec 2002
Article Copyright 2002 by lambo82669
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid