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
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,
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:
Submitting messages is equally easy via the
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.
- 12/03/2002 - Initial Submission
- 12/10/2002 - documented a dependancy