Click here to Skip to main content
12,820,031 members (29,722 online)
Click here to Skip to main content
Add your own
alternative version


27 bookmarked
Posted 3 Dec 2002

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


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? :)


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


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


About the Author

Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralWaste of time Pin
sytelus28-Jan-03 19:01
membersytelus28-Jan-03 19:01 
GeneralRe: Waste of time Pin
Anonymous20-May-04 16:48
sussAnonymous20-May-04 16:48 
GeneralNUnit Dependency Infomation Pin
lambo826695-Dec-02 6:42
memberlambo826695-Dec-02 6:42 
QuestionMissing? Pin
Rocky Moore5-Dec-02 1:28
memberRocky Moore5-Dec-02 1:28 
GeneralThis looks to be very useful Pin
Marc Clifton4-Dec-02 12:17
memberMarc Clifton4-Dec-02 12:17 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 10 Dec 2002
Article Copyright 2002 by lambo82669
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid