MassTransit MSMQ Viewer

by Daniel Halan 6. March 2014 16:35
Just released Service Bus MQ Manager version 4.10, which includes various bug fixes and a new Adapter for MassTransit, contributed by Juan J. Chiw. The Adapter supports viewing, managing of MSMQ Messages, Sending Commands and Viewing Event Subscriptions.  

 Go to Download page

Into the Clouds

by Daniel Halan 19. November 2013 14:05

For the past three years my focus has changed to almost exclusively building Distributed Systems, which has been both an earth-shattering and exciting experience. As most of the best practices one have used for the past 15 years not always apply, and often becoming anti-patterns. But it has been a treat to explore all the new technologies that have emerged during the last couple of years. As Visual Studio and C# .NET has been my primary weapons of choice the past decade, it was natural to explore Windows Azure and what it can provide as a PaaS platform.

And it has been truly amazing to see the fast-paced development of Windows Azure during the past years, as new services are announced frequently and the administration UI get continuously improved. And at times hard to keep up with the latest revisions of the SDKs and features, something developers are not spoiled with in other areas. Of course this comes with its share of issues, where one can come across some minor hick-up. But it really feels like Microsoft is going all in, into the Cloud.

Windows Azure Advisory Program

I feel very grateful to have been invited to be part of the Windows Azure Advisory Program, and be able to contribute to the development of Windows Azure Platform.

Service Bus MQ Manager v4.00 Released

by Daniel Halan 7. November 2013 15:11

Version 4 of Service Bus MQ Manager has been in development for a while now, and brings a better server and queue managment, where one can create a configuration per server connection defining different queues and Command paths. This comes in handy when running more then one project on the same server.

Also included in this release is support for NServiceBus v4, and a NServiceBus "Azure Service Bus" Adapter is currently being tested and hopefully released within the coming month.

 Go to Download page


Service Bus MQ Manager v3.00 Released

by Daniel Halan 25. March 2013 00:25

Just released v3.00 of Service Bus MQ Manager, it contains a complete source code overhaul, with a simpler Service Bus Adapter API and including following features,

  • Show Processed Messages, Load messages from the Journal queues. For use cases such as, show messages that got processed before Service Bus MQ Manager was started, or messages that where added and processed before the Service Bus monitor process discovered them.
  • Queue Colors, Set specific color per Queue, for easier overview of different categories of messages that span over queue types.
  • Resend Command, Easy access to resend a command, opens up the send command dialog so changes can be made before sent again.
  • JSON Messages, Now support for JSON serialized messages.
  • Error Stack Trace, View Stack Trace of Error messages
  • Perfomance improvments, Quicker loading times and less resource consuming when processing large amounts of messages.
  • Quick filter, Start typing and only messages with names containing the text will be shown

 Go to Download page


Deserializing objects with non-default constructors in JSON.NET

by Daniel Halan 5. January 2013 12:06

Recently I've come across the need to be able to serialize and deserialize objects with non-default constructors using JSON.NET. One way of doing this is to add JsonConstructor attribute to one (1) constructor and make sure that all parameter names does match the public properties names. But the problem arise when you don’t have control over the classes that should be serialized/deserialize, or just don't want to add JSON specific constructors mudding your objects.

So the other solution would be to have a fallback method whenever JSON.NET cannot find an appropriate constructor, giving an opportunity to analyze the class and call the appropriate constructor returning an instance of the newly created object.

Here follows example code of how it works,

public static T ReadJsonFile(string fileName) {

  if( File.Exists(fileName) ) {
    var s = new JsonSerializerSettings {
      ConstructorHandlingFallback = CtorFallback

    return (T)JsonConvert.DeserializeObject(File.ReadAllText(fileName), typeof(T), s);

  return default(T);

// Create new object instance using default values for constructor parameters
private static void CtorFallback(object sender, ConstructorHandlingFallbackEventArgs e) {
  List<object> args = new List<object>();
  foreach( var p in e.ObjectContract.Properties ) {
	args.Add(p.PropertyType.IsValueType ? Activator.CreateInstance(p.PropertyType) : null);

  e.Object = Activator.CreateInstance(e.ObjectContract.UnderlyingType, args.ToArray());

  e.Handled = true;

The modified JSON.NET library is a part of the Service Bus MQ Manager project at GitHub, the compiled version can be downloaded below, until this gets implemented in future versions of JSON.NET.

UPDATE 2013-10-06:
The project is now available as a Fork at GitHub updated to v5.0 R6 v4.5 r11 (479.28 kb)

This also solves the exception "Unable to find a constructor to use for type 'xxx'. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute" that JSON.NET throws where there are more then one parameterized public constructors and none public default constructor.


Service Bus MQ Manager v2.0 Released

by Daniel Halan 14. December 2012 16:25

Just released version 2.0 of Service Bus MQ Manager, the release includes Sending Commands, Viewing Subscriptions, in-application configuration and improvments in fetching messages before they gets processed. It has been tested with NServiceBus and MSMQ.

 Go to Download page

A MSMQ Viewer for NServiceBus

by Daniel Halan 5. October 2012 07:25

I've lately been working with a scalable cloud solution, and then it's good to use a Service Bus for sending commands, events and messages around the network. Now I tried few MSMQ message viewers that are available, but they all lacked the real-time feedback that would be nice when debugging or just want to know what is happening behind the scenes. So from that a new small application grew, called "ServiceBus MQ Manager". It's a small application that will monitor queues with a set interval, and present the Events, Commands and Messages that are there, but also keeping messages that has been retrieved (deleted) from the Queue.

One feature worth mentioning is that you can easily move messages that are in the Error queue to their original queue, just by selecting them and using the context menu.

Currently it has only been design and tested for NServiceBus using MSMQ, but it could easily be extended to use with any other Service Bus such as MassTransit and Azure Service Bus.

 Go to Download page

The source code is available at GitHub



Replaying events using Event Store with RavenDB

by Daniel Halan 29. February 2012 21:44

Been working lately with Event Sourcing and the CQRS pattern. One of the great features of Event Sourcing is to be able to change the view model schemas and simply replay all the events and let the event handlers rebuild all your view models. No more deltas to think about. Been using the Jonathan Oliver EventStore library together with RavenDB

Here is an example of a generic way of replaying all events, where all View Models stored in RavenDB implements an IViewModel interface. If you would have your IViewModel implementations in a different assembly from where the interface is, you will need to change the GetAssembly()-call to the correct one.

public void ReplayAllEvents() {
    Type viewModelInterface = typeof(IViewModel);
    Assembly viewModelAsm = Assembly.GetAssembly(viewModelInterface);

    // Delete all View Models
    using( var session = _readRep.OpenSession() ) {
        MethodInfo miQ = session.GetType().GetMethods().Where( mi => mi.Name == "Query" && 
								mi.GetParameters().Length == 0 && 
								mi.GetGenericArguments().Length == 1 ).Single();
        MethodInfo miDel = session.GetType().GetMethod("Delete");

        foreach( Type type in viewModelAsm.GetTypes()
								.Where(t => viewModelInterface.IsAssignableFrom(t)) ) {

		  var typeArr = new Type[] { type };
          foreach( var m in (IQueryable)miQ.MakeGenericMethod(typeArr).Invoke(session, null) )
            miDel.MakeGenericMethod(typeArr).Invoke(session, new []{ m });


    // Make sure the read model doesn't return stale results
    _readRep.RegisterListener(new NoStaleQueriesListener());

    // Dispatch all events again
    foreach( var commit in _eventStore.Advanced.GetFrom(DateTime.MinValue) ) {



Blog3ngine dot NET
Theme by Daniel Halan

About the author

Daniel Halan Daniel Halan, M.Sc., Microsoft Windows Azure Advisor Software Architect and Lead Developer from Sweden, currently in Bangkok.

Working primary with Microsoft .NET, Windows Azure, DDD, CQRS and some Dynamics CRM  Read more...

The content of this site are my own personal opinions and do not represent my employer's view in anyway.

Month List