The Freak Parade

Strange noises from the mind of Nathan Stults…
  • rss
  • Home
  • About The Freak Parade

Foundations of Programming - free ALT.NET e-book

June 27, 2008

I am constantly amazed (and humbled) by the generosity of time experts in this field of very, very busy people continue to demonstrate over and over again. I don’t know if other professions are the same way, but it really makes this one a pleasure to work in. Here is a free e-book by Karl Seguin of CodeBetter.com. I haven’t read it yet, but I very much look forward to it. From the TOC it looks like it will be a very useful resource.

You can get it here.

image

Comments
Comments
Categories
Uncategorized
Comments rss Comments rss
Trackback Trackback

Baby Stepping into MSIL - creating an "Event Recorder" using a DynamicMethod and Reflection.Emit

I’ve often been caught between two opposing forces - the desire to find some excuse to use Reflection.Emit to dynamically generate behavior, because it has a sort of magical quality about it, and on the other hand being completely intimidated by the strange and foreboding mysteries of IL. I finally found an excuse compelling enough to brave my fears and stick my toe in the water, and it wasn’t too bad.

The excuse to take the plunge was, as is often the case, laziness (or perhaps impatience). I had an interface with a blue million events on it, and I wanted create some unit tests that ensured all my little events were fired the right number of times, in the right order, with the right arguments, but I didn’t want to subscribe to all the events individually and set a bunch of flags, etc. etc. (BTW - I imagine this problem has been solved by superior minds - I didn’t spend much time looking)

[UPDATE] Here is a CodeProject article explaining how to do essentially the same thing as EventRecorder without using Reflection.Emit. Instead, an EventProxy intermediary class is used to store the EventName. http://www.codeproject.com/KB/cs/eventtracingviareflection.aspx 

The sample code, along with unit tests and a Windows Forms app demonstrating possible usage, can be found here.

Here is a typical usage:


[Test]
public void Recorder_Will_Record_Events()
{
    var source = new TestEventSource();
    using (var recorder = new EventRecorder(source))
    {
      source.FireSimpleEvent();
      source.FireSimpleEvent();
      source.FireEventWithCustomArgs("MyTestText");
      source.FireSimpleEvent();
      source.FireEventWithCustomArgs("NewTestText");

      Assert.That(recorder.EventHistory.Length, Is.EqualTo(5));

      Assert.That(((TestEventArgs) recorder.EventHistory[2].Args).LoveMe, Is.EqualTo("MyTestText"));
      Assert.That(((TestEventArgs) recorder.EventHistory[4].Args).LoveMe, Is.EqualTo("NewTestText"));

      Assert.That(recorder.GetInvocationsFor("SimpleEvent").Length, Is.EqualTo(3));
      Assert.That(recorder.GetInvocationsFor("EventWithCustomargs").Length, Is.EqualTo(2));
     }
}

What I wanted to do was "record" all the events that were fired on a particular object during the course of some transaction, and then test that all the events that fired were the ones I was expecting, and in the appropriate order. I figured I would achieve this by creating a class called EventRecorder that could take in its constructor any other non-null object. It would then loop through each event in the objects type, subscribe to that event, and when the event fired add the name of the event and the EventArgs to a collection I could examine later. Pretty simple.

I though this would be a simple matter of using some plain ol’ reflection, like this:


foreach (EventInfo evt in eventSource.GetType().GetEvents())
 {
 	evt.AddEventHandler(eventSource,
            new EventHandler(
		(sender,args)=>RecordEvent(evt.Name,args)));
 }

But alas, AddEventHandler expects a delegate that exactly matches the signature of the event, meaning if I have an event defined with EventHandler<CancelEventArgs>, it isn’t going to let me pass a plain EventHandler delegate. So what to do? Dynamically generate an event handler with the appropriate signature, of course, and emit a simple call to my RecordMethod. Essentially, we’ll be generating the equivalent of this:


private void HandleEvent(object sender,EventArgs<canceleventargs> args)
{
    this.RecordEvent(args,"NameOfTheEvent");
}

I found an MSDN article that looked like just the ticket. The technique presented uses the DynamicMethod class, which you can use to create an ad hoc method and fill it full of op-codes to tell it what to do. In this case, we wanted to instantiate a DynamicMethod that matches the signature of the event handler we want to subscribe to. Then we simply needed to emit the IL to call the RecordEvent method and pass in the appropriate arguments. In the code below, EventSource refers to the object whose events we’re subscribing to, and was passed in to the constructor of the EventRecorder class.


/// <summary>
/// This method crates a DynamicMethod matching the signature of
/// the delegate required by the passed in EventInfo. The method
/// will simply pass the arguments on to the RecordEvent method.
/// </summary>
/// <param name="evt"></param>
protected void BindToEvent(EventInfo evt)
{
    Type handlerType = evt.EventHandlerType;

    if (handlerType == null)
        throw new ArgumentException("No handler could be " +
                              " identified for " + evt.Name);

    Type[] handlerParams = GetDelegateParameterTypes(handlerType);

    //Not technically required, but may be helpful if an exception is thrown
    String dynamicHandlerName =
        String.Format("EventSource_{0}", evt.Name);

    var handlerDef = new DynamicMethod(dynamicHandlerName,
                                       typeof(void),
                                       handlerParams,
                                       typeof (EventRecorder));

    MethodInfo recordEvent =
        typeof (EventRecorder).GetMethod(
            "RecordEvent",
             BindingFlags.Instance | BindingFlags.NonPublic);

    ILGenerator ilgen = handlerDef.GetILGenerator();

    //load 'this' onto the stack
    ilgen.Emit(OpCodes.Ldarg_0);

    //load the second argument (EventArgs) onto the stack
    //We're not using the sender parameterf of the delegate,
    //so we skip emitting OpCodes.Ldarg_1
    ilgen.Emit(OpCodes.Ldarg_2);

    //Load the name of the event onto the stack
    ilgen.Emit(OpCodes.Ldstr, evt.Name);

    //Call the RecordEvent method, passing the two loaded argumetns
    //EventArgs args and String name
    ilgen.Emit(OpCodes.Callvirt, recordEvent);

    //Return control
    ilgen.Emit(OpCodes.Ret);

    //Create a delegate out of this new handler, binding to the current
    //instance as the target
    Delegate handler = handlerDef.CreateDelegate(handlerType,this);

    try
    {
        //Register the new delegeate with the event on the event source
        evt.AddEventHandler(EventSource, handler);
    }
    catch (Exception ex)
    {
        //Some COM objects don't like this method. In production, you wouldn't
        //eat this error like this, but for my example, I wanted to show events
        //on the WebBrowser control, and certain events of WebBrowser
        //don't appreciate this dynamic approach. So...
    }

    //record this handler so we can get to it later
    //when we need to remove our registration from
    //the event source during dispose
    _handlers.Add(evt.Name, new EventRef(handler,evt));
}

/// <summary>
/// Extract the signature of the event's delegate
/// </summary>
/// <param name="d"></param>
/// <returns></returns>
private static Type[] GetDelegateParameterTypes(Type d)
{
    if (d.BaseType != typeof (MulticastDelegate))
        throw new ApplicationException(
            d.Name + " is not a delegate.");

    MethodInfo invoke = d.GetMethod("Invoke");

    ParameterInfo[] parameters = invoke.GetParameters();

    //Allocate an extra slot, see below for why
    var typeParameters = new Type[parameters.Length+1];

    for (int i = 0; i < parameters.Length; i++)
    {
        typeParameters[i+1] = parameters[i].ParameterType;
    }

    //This is an extremely important step - we need to inject the type
    //of EventRecorder because we will be using EventRecorder as the Target
    //of the dynamic delegate that we create using the DynamicMethod. When
    //you go to convert your emitted MSIL to an actual delegate using DynamicMethod.CreateDelegate,
    //the first argument of the signature MUST match the target object you are binding
    //the delegate to.
    typeParameters[0] = typeof (EventRecorder);

    return typeParameters;
}

/// <summary>
/// The internal method that gets called by the dynamically
/// generated delegates we are using to bind to the EventSource's
/// events. This method will get called once for every event that fires
/// on the EventSource.
///
/// <param name="args"></param>
/// <param name="eventName"></param>
protected virtual void RecordEvent(EventArgs args, string eventName)
{
    EventInfo evt = _handlers[eventName].Event;

    if (evt != null)
    {
        var history = new EventInvocation { Args = args, Event = evt };
        _eventHistory.Add(history);
        OnEventRecorded(history);
    }
}

IL is pretty close to the machine, relative to C#, so it’s entirely stack based. You load arguments onto the call stack, then perform an operation, such as calling a method. If you call a method, and the method has a signature with arguments, the arguments for the method signature are popped off the stack and consumed.

In this example we’re generating a dynamic method with a signature of two visible arguments - (object,MyEventArgs) - but we’re calling a method (RecordEvent) with a slightly different signature (EventArgs,string). We can discard the "object" argument of the dynamic method, which we do simply by not loading it onto the stack, which is why we don’t emit the opcode Ldarg_1, but we need to load the EventArgs and a string.

Looking at my source code it doesn’t quite add up though, because you can see I’m loading argument 0 (Ldarg_0) which looks like it should be "object" based on the dynamic method signature and argument 2 (Ldarg_2) which doesn’t even seem like it should exist, as the signature is (object,EventArgs) - only two arguments. Well, it turns out that all instance methods require a 0 position argument that is "this" - this argument is inserted by the compiler so you never see it, but when you say "this.DoSomething()" in your code, in IL method signature that gets created is DoSomething(MyType this). That means our call to "RecordEvent(EventArgs,string)" really looks like this: "RecordEvent(EventRecorder,EventArgs,string)", which means we need to load 3 variables onto the stack, which we do:

Ldarg_0 = this

//Ldarg_1 = object - not needed

Ldarg_2 = EventArgs

Ldsstr = EventInfo.Name

NOT calling Ldarg_1 discards the object part of the dynamic method signature, which is OK, because that just represents EventSource anyway, and we have a reference to that already.

One important thing to note, though, is that when calling CreateDelegate on DynamicMethod it is critical to pass in "this" as the target - otherwise when the method you generated tries to access member variables, you’ll get illegal memory access errors. Also subtle, if you are creating a dynamic method that you intend to bind to an instance of an object, then the DynamicMethod needs to be created using the secret, full signature of MyMethod(EventRecorder,object,EventArgs) NOT just MyMethod(object,EventArgs) as you would expect. You can see this being taken care of in the GetDelegateParameterTypes method. This piece of info was not in the MSDN sample, and was a just a joy to figure out :)

By the way - a great way to figure out just what IL you need is to write the method you are hoping to generate, compile it, then view the IL in ILDASM.exe. Then you can either blindly translate the IL into Opcode.xxx calls, or you try to understand why it is doing what it is doing and modify according to your needs, but I probably never would have figured out the Ldarg_0 / Ldarg_2 mystery on my own - ILDASM saved my butt.

I need to find a better way of debugging this stuff, but the fact of the matters is that once you see what is going on, IL isn’t really any more complicated than anything else, it is just far more verbose and cryptic when you get it wrong :)

The rest of EventRecorder is nothing special. The sample includes unit tests and a simple windows forms example.

Here are some resources:

DynamicMethod.CreateDelegate Method

How to hook up a delegate using reflection

Reflection.Emit tidbits

Introduction to creating types with Reflection.Emit, DymamicMethod

Comments
Comments
Categories
Uncategorized
Comments rss Comments rss
Trackback Trackback

SimpleServiceBus Getting Started Guide

June 24, 2008

imageA “getting-started” tutorial on how to get up and running with Simple Service Bus is available here. The guide explains various methods of configuring endpoints, how to define, send and publish messages, how to create and register message handlers, as well as how to setup the endpoint health monitoring system that is part of the framework. Much of what is presented will also apply to nServiceBus, since until you start getting into extensibility SSB hasn’t made many changes, but the syntax and configuration does differ in a number of places, so adjustments would need to be made.

Comments
Comments
Categories
ESB, Messaging, NServiceBus, SOA, SSB, Simple Service Bus
Comments rss Comments rss
Trackback Trackback

Test Patterns: State vs Behavior Verification

This site gives a good definition of State Verification and Behavior Verification as it concerns our efforts to establish unit tests for all new functionality.

State Verification
Behavior Verification

Heres the one line definition for each if you want the 50,000 foot view.

State Verification: We inspect the state of the system under test (SUT) after it has been exercised and compare it to the expected state.

State Verification

Behavior Verification: We capture the indirect outputs of the SUT as they occur and compare them to the expected behavior.

Behavior Verification

Its a subtle but important distinction in that with state verification you may run a series of method call or processes and verify the expected state of the system after all the call have been made. With behavior verification you are interested in verifying that individual method calls are made to components within the system under test including dependent components utilized by the system under test.

Comments
Comments
Categories
TDD, Testing
Tags
TDD, Testing
Comments rss Comments rss
Trackback Trackback

SimpleServiceBus Overview & Architectural Description

June 23, 2008

I have posted a comprehensive overview of Simple Service Bus, including an architectural description, in the form of a PDF document available here. A few images from this document are included below.

image image

Comments
Comments
Categories
ESB, Messaging, NServiceBus, SOA, SSB, Simple Service Bus
Comments rss Comments rss
Trackback Trackback

SimpleServiceBus on CodePlex (a fork of nServiceBus)

June 17, 2008

[UPDATE] A pdf document providing a comprehensive overview of the project is now available here.[/Update]

I have posted a new project on CodePlex, Simple Service Bus. Simple Service Bus is a derivative of Udi Dahan’s nServiceBus, which I’ve mentioned before. I’ll be posting some more extended samples and documentation for using the new library, but first I wanted to document my motivations. nServiceBus is a very solid, very useful, very easy to use piece of software for building asynchronous, messaging based service endpoints, and it’s creator is a well respected SOA guru, at least in .NET circles. I, of course, have no such pedigree, which is why I chose to start with nServiceBus as a foundation rather than starting from scratch.

So what is wrong with nServiceBus that required us to fork it? Well, nothing. My take on nServiceBus and the direction Udi Dahan seems to take the project is that it is a library designed to provide just enough rope to get the job done, but not enough rope for us developers or architects to hang ourselves from a scalability and reliability perspective as we wade into the asynchronous, messaging based waters for the first time. This is a very useful trait for a library to have. However, such an approach comes with some tradeoffs, namely when it comes to extensibility and customization, and I’m a lego brick kind of guy, maybe stemming from control issues, who knows :)
In service, I believe, of the protective and prescriptive nature of the project, nServiceBus has many of its most interesting parts “soldered to the motherboard” - their implementation is blended in with the default implementation of the framework itself, which means that if you want to customize how certain things work, you have to diverge from the codebase. Now, to be fair, this is only true to a certain extent. nServiceBus has several major pieces that can be swapped out, such as IBus and ITransport, but within the responsibilities of the default implementations of IBus or ITransport are a number of smaller components that can’t easily be customized.

It hardly seems necessary to go so far as to fork the project when custom IBus and ITransport implementations could have accomplished 95% of the flexibility I was going for. And, in reality, it probably wasn’t necessary - but once the thing was already on the operating table, I couldn’t resist making some preference based changes to the IBus API, and I wanted to add custom headers to the message envelope (which crosses between IBus and ITransport) and at that point there really wasn’t any turning back.

Another question would be, well, if nServiceBus didn’t have the extensibility you were after, why not choose Mass Transit? It is extensible. And, in fact, it is - but it is still fairly young, and we’ll be going into production very soon. nServiceBus has been through the fires a few times, and I figured I could add the hooks I needed without altering the fundamental design of how nServiceBus operates, which I quite like and I’ll sleep better at night because of it. My belief, though, that if it was six or eight months from now, Mass Transit would have been the direction I’d have taken. Also, I already had a project, NsbExtensions, that implemented endpoint health & performance monitoring features on top of nServiceBus, and I wanted to be able to reuse all that code.

Here are the design goals of Simple Service Bus - most but not all of which are realized but not thoroughly tested in the version currently posted to CodePlex:

* Small DLL footprint - nServiceBus (for valid architectural reasons) is split up into eleven thousand, two hundred and nine different DLL’s. That may be an exaggeration, but many of the dll’s have only one or two code files in them, with only a few lines of code each. Simple Service Bus comes in three DLL’s for a normal endpoint, and add’s a fourth to implement an Endpoint Health Monitoring Server. Also, required third party dependencies are kept to a minimum (0).

* Custom headers in the Message Envelope - I wanted to be able to attach bits of information that are necessary for the messaging system to function properly, like authentication tokens or endpoint ID’s, without having to include those pieces of irrelevant data on the otherwise domain-oriented messages themselves. This results in a somewhat cleaner set of message contracts, but it also allows you to do some content based routing or authentication checks on a message before the payload ever has to waste the CPU’s time on deserialization. If a message is going to be blocked due to lack of authorization, or re-directed to a different endpoint, or simply written to disk as part of an audit process, there is no need to send the payload through the de-serialization / messaging handling process.

* Send and Receive Pipeline Pattern for Message Processing - instead of having a hard-coded path from Transport through final Handling, Simple Service Bus provides a configurable Pipeline approach, where each interesting step in the messaging processing process is implemented as a pipeline component. This allows programmers to add, for example, a content based message router ahead of the payload deserialization component, or to add a statistics gathering component at various places within the pipeline. Additionally, a rich set of events are fired while a pipeline is processing a message, allowing fine grained performance monitoring or logging if required.

* Replaceable Subsystems - each major concern of the bus has been factored into a simple subsystem as defined by an interface. The default implementation of any subsystem can easily be replaced. For example there is a Message Dispatcher subsystem, a Subscription Manager subsystem, a Message Serialization subsystem, a Message Type to Message Handler Resolution subsystem…etc. In this way, if you want to implement a Subscription Manager that can evaluate publisher-side expressions to determine whether or not to send a message to a particular subscriber using a custom DSL or any other expression evaluator, you can easily swap out the existing subscription manager with your enhanced one. And you can do it for just one endpoint, if only one endpoint needs that special functionality.

* IoC supported, but not required. The building of objects is handled by subsystem as well, and the default implementation can be given a reference to an IoC container to build all objects and services, or it can use simple reflection if no IoC is provided. To accommodate this, a Service Locator was used rather than a pure dependency injection approach, but the services registered with the Service Locator can optionally be built with an IoC. Also, of course, all Message Handlers and Pipeline Components will be constructed on demand using an IoC if provided, or simple reflection otherwise.

* Polymorphic Message Handlers - the default Message Handler Resolution Service allows message handlers to be defined for interfaces or base classes, allowing the creation of message handlers for families or categories of messages rather than just individual messages. This also applies to subscriptions, meaning that an endpoint can, for instance, subscribe to IEventMessage, and receive all messages that implement that interface, instead of being required to subscribe to each concrete message type.

* Endpoint Health & Performance Monitoring built into the core library - all endpoints can be configured to provide status reports to a monitor service with a few lines in the configuration file.

* Simplified Configuration - this is debatable, because Udi Dahan has gone to significant lengths to partition “programmer configuration” from “administrator configuration” - the former being accomplished in code and the latter being accomplished in a configuration file. This is probably a wise, experienced based approach, but I myself like the option to configure everything in a single, simple block of XML, if XML is being used. So that is how Simple Service Bus does configuration, in a more traditional manner.

* Abstract base classes provided for easily creating custom Transports, Pipeline Components, Performance Probes, etc., abstracting much of the ugly details and allowing the system to be extended by overriding a few simple, targeted methods.

* Fully Unit Tested - this isn’t finished yet (I’m still trying to get the hang of TDD, so the tests weren’t written first in this case) but the idea is to have unit tests for each piece of the system, allowing modifications or customizations to be done in a safe, controlled manner.

*object based API. I removed the IMessage marker interface for Simple Service Bus because (perhaps mostly for aesthetic reasons) I wanted our Message Definition dll’s to be as clean and reference free as possible. So now Send, Publish, etc. operate on System.Object rather than IMessage.

And that’s about it. I fell in love with Gregor Hohpe’s “Enterprise Integration Patterns” and wanted to apply those patterns to my own evolving messaging system, so this effort is sort of centered around enabling nServiceBus to accommodate that desire in a clean, plug and play way. We’ll see how it goes.

Comments
Comments
Categories
ESB, Messaging, NServiceBus, Open Source, SOA
Comments rss Comments rss
Trackback Trackback

A new ISB (Internet Service Bus) in beta testing - Linxter

June 11, 2008

Home

Similar to BizTalk services, minus the workflow/identity piece but plus a fairly robust security model and web based management dashboard, Linxter(http://www.linxter.com) provides a secure, queued transport for .NET applications. Essentially the service acts as a hosted messaging queue with an extremely simple (in a good way) API and an interesting ability to optionally send file attachments with your messages, which right off the bat gives it an edge over MSMQ over HTTP in my mind. Applications using this API will request registration with a central account on startup and security settings determine if the connection is automatically granted or if an administrator has to manually grant access to your bus to the endpoint. Once access is granted, endpoints (via the Linxter SDK) can send messages and receive messages in either an “on-demand” pull model or an event based push model. The service also supports broadcasting messages to multiple endpoints.

This isn’t something that could act as an ESB, but it could certainly act as a transport for an ESB. The service doesn’t have any pricing announced and the user agreement forbids production or commercial use, but it is something to watch if such a service would be useful to you.

In our case it would be perfect for connecting client systems to our hosted solutions without having to deal with ensuring MSMQ w/HTTP support is properly installed on each endpoint machine, and ensuring the proper queues are set up, etc. Much easier deployment and maintenance for remote nodes not in our firewall. If all your endpoints are inside your firewall, a hosted queuing service may be of little value, but if you have endpoints in the wooly wild, a service like this could be invaluable, taking care of endpoint authorization, identification, and all the rest.

Here is a link to the current stage of development, which appears to be nearing the end of Beta 2

Comments
Comments
Categories
API, ESB, Messaging, SOA
Comments rss Comments rss
Trackback Trackback

Fine, SOA may not be a City. What about a religion?

June 5, 2008

Rob Eamon has offered some compelling, well cited arguments (corrections?) in regards to a previous post of mine describing the image of SOA as a city/society that I selected from among various alternatives to use as a mental model. See the comments of that post for a full record of his take on things.

I can’t help but wonder, though, assuming his understanding is the original understanding, that the original “scope independent” definition he has laid out for the term SOA is mutating or fracturing into a different meaning, or more probably collection of meanings, as the concept is becoming more and more mainstream. Perhaps the mutation, if is real, is fueled by relative “laymen” from such out of the way places as the SMB (such as myself) as we attempt to understand SOA and become practitioners, which perhaps wasn’t common until more recently.

Or perhaps I say that entirely defensively, not wanting to believe I could have missed the mark by such a large margin.

In any case, I certainly have no other option than to concede that I was incorrect in my naive belief that I had found for myself a way of thinking about SOA that, at least in a purely conceptual fashion, could exist at an abstract level above all the tumultuous debate.

Perhaps believing in an image of SOA that encompasses all possible schools is as foolish as believing in an image of god that includes all other religions. I never get used to how much technology feels like religion to me at times.

Maybe things would be more straightforward for everyone if there were named schools of thought one could subscribe to, and then it wouldn’t be so tempting to say “This, well THIS is SOA, and that, well that is something that may resemble SOA(maybe), but in fact it is nothing of the sort.” Rather I could just say “I am a Soascopist” and you could say “I am a Soastylist” and, like religion, an argument about which is right would inevitably continue to rage. But, when the uninitiated like myself walk into a room of people shouting different definitions over each others heads, we would clearly know we needed to pick a school, learn the dogma and start shouting back, or we could state ourselves as agnostics, but we would be less inclined to try and synthesize the “truth” from all of the various contradictory opinions, which turns out to be a rather futile effort.

Then, when the holy war breaks out (and perhaps it already has), the SoaScopists, the SoaStylists and all other various sects of Soaists will take up arms together beneath a common standard and ally themselves against the RPCists. Gifted with superior agility, close strategic and financial alignment with the emperor, and extraordinarily loose coupling, the Soasists will relegate RPC to the level of an outcast technology, kept on life support on the outskirts of the kingdom via a flimsy service adapter, until some data center technician coldly pulls the plug, changes a value in a routing table, and the lights go out for good.

Of course, however it shakes out, we’ll still always prostate ourselves before the dollar, one way or another.

Amen.

(BTW, the holy war is just a joke, not my new personal metaphor for the relationship between SOA and RPC)

Comments
Comments
Categories
General, SOA
Comments rss Comments rss
Trackback Trackback

Create Bullet Graphs with Google Charts in 7 Easy Steps

I haven’t paid much attention to Google Charts so far, but I have enjoyed Stephen Few’s “Bullet Graphs.” A bullet graph is an extremely condensed sort of bar chart that shows the current value of a KPI, and various ranges such as unacceptable, acceptable and target, and an optional indicator line that can mean several things. Anyway, here is an example of a bullet chart (from wikipedia):

 

Bullet graph labeled.png

 

This blog post referenced below was referenced in Stephen Few’s blog this morning and describes the several easy steps required to create a bullet graph using the Google API. Being able to easily throw these things up, ad hoc, in any web page is pretty phenomenal, if you ask me. The image below is actually a Google Graph:

 

Here is the link to the guide:

DEALER DIAGNOSTICS » Blog Archive » Create Bullet Graphs with Google Charts in 7 Easy Steps

Comments
Comments
Categories
API, Graphics & Design, Tools, Visualization
Comments rss Comments rss
Trackback Trackback

ESB’s for the Microsoft (.NET) Platform

June 3, 2008

I did a pretty exhaustive search for an ESB recently for use on a project that we’re getting underway. FYI, my selection criteria was coming from the point of view of an SMB, so we probably emphasized simplicity and ease of use over scalability and robust governance tools, for instance. Also, cost was a big factor, so the big infrastructure vendors weren’t even on the radar, even though I’m sure they could be used quite easily in a .NET environment.

Anyway, there weren’t all that many options. I guess I wasn’t surprised, but I was a little disappointed. The Java community has half a dozen or more full blown open source ESB projects, many with professional support organizations where you can buy support and consulting if you need it.

In .NET land there wasn’t anything like that. Here is what I found:

BizTalk Server + BizTalk ESB Guidance = ESB ?

Initially I assumed we’d be going down this path, so I read a really great book by Darren Jefford on the subject. BizTalk is a pretty deep piece of software, but like a lot of Microsoft frameworks it aims to be all things to all people, and we wouldn’t need 75% of what it provides and it didn’t offer the simplicity of development, maintenance and deployment I was looking for. The business rules chapter of the book opened up with a warning that the BRE in BizTalk is complicated beyond measure, yet you should learn it because it is powerful. To make it an interpretation of an ESB you apply the ESB guidance put out by Microsoft that I have heard eventually was the jumping off point for Neuron (possibly I made this up in my head), but the guidance exists and seemed to have quite a few moving parts. The installation instructions and prerequisites weren’t a walk in the park, and the whole itinerary based approach isn’t quite what we needed. We were looking for dead simple Send, Receive, Publish, Subscribe semantics in a code based API. BizTalk is a lot of things, but not those things, so the search continued.

Neudesic’s Neuron ESB

Next up we evaluated Neuron. This is really a pretty fantastic product that combines the easy API I was looking for with all the powerful translation, BAM and orchestration of BizTalk (but you need to license both products, I don’t believe Neuron offers these features separately) with a ton of flexibility and some great centralized endpoint configuration mechanisms. From what I gather they pretty much pulled BizTalk apart and exposed the functionality of its pieces (orchestrations, BAM, transformations, adapters, etc) directly via their messaging API and bypassed the MessageBox entirely, which is a pretty slick trick.  Without BizTalk, I think Neuron still offers an alternative to orchestrations using integration points with WF and like BizTalk has a pretty good set of legacy systems adapters. Still, even though Neuron is orders of magnitude less expensive than the big dollar enterprise ESB’s, it was still more than we wanted to spend, mostly because our messaging needs were so simple.

Mass Transit

This is a pretty new open source project, currently at version .1. The code is really pretty interesting, there seem to be plenty of extensibility points and the test coverage is very good. Lot’s of moving parts in this one too, but it is a rapidly evolving project. I’ve been keeping an eye on the code as it moves from .1 to .2 and the API is changing rapidly. I think this is definitely worth keeping an eye on, but as of this exact moment in time the API is a bit too volatile, as you would expect in a .1 version. Once it cooks for a while and sees some use I think it will be a nice alternative to the others on this page. Also, they have an NMS transport for integrating with ActiveMQ, although that may not be ready yet.

nServiceBus

This is a relatively mature open source project currently at version 1.8 (RC2 or something) and from accounts has been used in some pretty demanding, large scale production applications. It is a one man show, from what I can tell, run by Udi Dahan, who has given himself the moniker of “The Software Simplist” and I think that shows in his service bus. nServiceBus has the least number of moving parts and it is very easy to understand the entire code base without furrowing your brow. It is trivial to set up endpoints and get them sending, receiving, publishing and subscribing. This is the library we are tentatively using in our project. I wish, at times, it had a few more extensibility points, or were a little more modular, as it comes apart in roughly three or four big pieces. You can replace any of the big pieces, but there isn’t a whole lot of customization or modularization within the pieces. My belief is that Udi Dahan vigorously defends the simplicity of his project and avoids adding what he considers complexity for the sake of extensibility he doesn’t see the value of. By and large I would say nServiceBus codifies a particular approach to service buses and SOA in general and is deliberately designed to enforce that philosophy. Actually, I think the website says something to that effect too. One nice thing about nServiceBus is that Udi Dahan has lots of blog posts and pod casts discussing in articulate detail his SOA philosophy, which if you agree with it will you find direct support for those ideas in the project. The thing comes with a MSMQ transport, but the contrib project has an ActiveMQ transport and it sounds like an HTTP Transport will arrive shortly with a WCF/MSMQ transport coming at some indeterminate time after that. [Update] We’re now using Simple Service Bus, our own derivative of NSB, description below


Simple Service Bus

Simple Service Bus is a derivative (fork) of nServiceBus. Full details on the project can be found here, but the idea was to take the reliability and simple API found in nServiceBus and add in the extensibility and modularity required to enable us to design messaging systems in a more “building block” way, for better or worse. A pdf document providing a comprehensive overview of the project, including an architectural description / diagram, can be downloaded here. The project home page on CodePlex is here.

BizTalk Services

Microsoft is building a SaaS messaging bus with some slick features, orchestrations via WF and more significantly, I think, some sort of federated identity service using (I believe) a standards based STS service. However, it is currently in CTP and is not at all ready for production use (according tot he website). Plus, nobody knows what it will cost.  I think it is designed for partner-partner integrations and I’m not sure if it is intended for the Internet Service Bus (ISB, what they are calling BizTalk services) to be a replacement for an Enterprise Service Bus, but perhaps a compliment. Not sure on that one though. In any case, it is worth watching (and possibly playing with if you have time) but not an option for production use just yet.


Linxter ISB

Another ISB in beta, this service is similar ( I think ) to the core purpose of BizTalk services (hosted, secure messaging across the open Internet), with a slightly different feature set. I posted about Linxter here.

That
’s all I could find. Personally, I think there is room for more. Resources below. Links to project/product home pages are in the titles of the products themselves.

Neuron-ESB-vs.-Microsoft-ESB-Guidance-A-Quick-Comparison

Neuron posts from Sam Gentile

NServiceBus - Makes Building Enterprise .NET Systems Easier

http://udidahan.weblogs.us/

Mass Transit author blog

Very brief review of Mass Transit code

Simple Service Bus - Overview & Architectural Description

Comments
Comments
Categories
ESB, NMS, NServiceBus, SOA, WCF
Comments rss Comments rss
Trackback Trackback

« Previous Entries

Subscribe

Calendar

June 2008
M T W T F S S
« May   Jul »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Recent Posts

  • You Can’t Fill an Imaginary Hole
  • I don’t know but I’ve been told, ETL is gettin’ mighty old. BAM! BAM! EDA! I want my data right away!
  • Be Prepared To Be Surprised
  • Google Chrome, I could kiss you! (Or, multi-process browsers are a really good idea)
  • New Open Source .NET CMS/EPS Platform Released Today: Sense/Net 6.0 Beta 1

Recent Comments

  • Ashwani on Rule Based Access Control using an Expression Evaluator
  • Richers Blog on Identity’s new Identity - Part 3, The Technology
  • sandra on ESB’s for the Microsoft (.NET) Platform
  • nstults on Content Management Systems (CMS) for the .NET Platform
  • Adz on Content Management Systems (CMS) for the .NET Platform

Tags

TDD Testing

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox