Duplex WCF “Service Bus”: Part 1

By | August 7, 2012

We’ve created a mini service bus for use here at work. Many of our services and client applications require information from each other. Sometimes to display active states, sometimes to take action on incoming data. Regardless, we need information delivered to many different endpoints, in an event-like fashion (non-polling).

We started out with this post from Juval Lowy “What you need to know about one-way calls, callbacks and Events.” This was a great starting point for us because it did most of what we wanted: publish and subscribe.

What it did not do was allow for ad-hoc publishing (and subscribing).  All of your callback methods had to be defined.  It was more of WCF method callback framework than a actual service bus.  While there are many free and purchasable ESBs around, our company dislikes using open-source, and purchasing a large ESB didn’t really make sense for our needs.  We needed something lightweight and easy to use.

Using the callback framework, I added just a few simple methods to the classes to allow for generic serialized XML data to be published, and that data to be subscribed to by name alone.  This allows anyone with access to the bus to publish any data they want, under any name they want.  No recompilation required.

Published data is serialized before sending.  The bus always expects an XElement.  It is up to the subscriber to know how to decode the XML into something useful (generally by deserializing the XElement into a known object).

In Part 2, I go into more detail about how it works.

Leave a Reply

Your email address will not be published. Required fields are marked *