Archives

Archives / 2011 / September
  • Command Handling the Nancy Way

    minibuss_small_thumb1_thumb_thumb MiniBuss is a micro service bus framework over msmq which consists of less than 400 lines of code, sitting inside one single source file. The project is hosted over at http://minibuss.codeplex.com and the source code is maintained at https://github.com/johandanforth/MiniBuss

    I’ve been a fan of the Sinatra inspired web framework called Nancy, especially the neat way of setting up handlers for routes. The simplest sample on their site is this:

    public class Module : NancyModule
    {
        public Module()
        {
            Get["/greet/{name}"] = x => {
                return string.Concat("Hello ", x.name);
            };
        }
    }

    So, I shamelessly dug into the Nancy code and borrowed some 20-30 lines of code and came up with something like this for registering handlers for certain incoming commands on the minibus, what do you think?

    public class CommandHandler : MessageHandler
    {
        public CommandHandler()
        {
            WhenReceiving[typeof(SampleMessage1)] = x =>
            {
                Console.WriteLine("sample 1 message: " + x.Text);
            };
    
            WhenReceiving[typeof(SampleMessage2)] = x =>
            {
                Console.WriteLine("sample 2 message: " + x.Text);
            };
        }
    }

    It’s a bit more code but it helps/enforces you to move the handlers off to a certain module. Thoughts?

  • More MiniBuss Updates

    minibuss_small_thumb1_thumb MiniBuss is a micro service bus framework over msmq which consists of less than 400 lines of code, sitting inside one single source file. The project is hosted over at http://minibuss.codeplex.com

    Thanks to @CodingInsomnia for testing out the MiniBuss stuff a bit more than I did Winking smile For the samples, and for my initial testing code, I used a shared assembly with messages (events and commands), which shouldn’t be necessary. So I made a few simple changes and now you can choose to either share messages in an assembly between your sender/receiver and publisher/subscribers OR you can declare local message classes as long as those classes use the same class name and properties it should work.

    The NuGet package has been updated, and the new code is in package version 1.0.2.0.

  • MiniBuss Updates

    minibuss_small_thumb1 I made a small update to MiniBuss, the micro service bus framework. The messages you send, Commands and Events, are no longer dependent on IMessage. The messages sent on the bus can now be any .NET class which can be safely serialized.

    The MiniBuss package on NuGet has been updated (version 1.1.0.1).

    I’m looking for testers, reviewers and co-authors. Areas I want to look more at are multithreading/concurrency and the reply-feature (especially being able to reply to current message in multithreaded scenarios.