Saturday 4 May 2013

Fix for NServiceBus testing.

Looks like the issue I had with NSB testing may not have been the Unobtrusive messages.

What I’ve ended up having to do is this.

   1:  MessageConventionExtensions.IsMessageTypeAction =
   2:                  t => t.Namespace != null && t.Namespace.EndsWith("Messages") && !t.Namespace.StartsWith("NServiceBus");
   3:  Test.Initialize();

Making ConfigurationElementCollection strongly typed.

I was getting annoyed with ConfigurationElementCollection returning IEnumerable and not IEnumerable<T>, after some Googling I came across this post on StackOverflow http://stackoverflow.com/questions/7991252/read-web-config-section-to-list.

Basically you implement IEnumerable<T> and in GetEnumerator do this

   1:   public new IEnumerator<T> GetEnumerator()
   2:   {
   3:      return this.OfType<T>().GetEnumerator();
   4:   }



No more casting when you want to use Linq on the ConfigurationElementCollection Thumbs up

Friday 5 April 2013

Object reference during NServiceBus start up.

One of our NServiceBus services started getting this error today.

Fatal    System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Object.GetType()
   at NServiceBus.Timeout.Core.TimeoutRunner.CacheExistingTimeouts()
   at NServiceBus.Timeout.Core.TimeoutRunner.Run()
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start(Action startupAction)
   at NServiceBus.Hosting.GenericHost.Start() in c:\TeamCity\buildAgent\work\nsb.master_8\src\hosting\NServiceBus.Hosting\GenericHost.cs:line 34

Turns out the NServiceBus.Persistence connection string was pointing to a Raven instance that was turned off.

Friday 29 March 2013

NServiceBus Testing with Unobtrusive messages

I’ve just had a problem when using nServiceBus.Testing.

When I was running my unit test i was getting
image

Turns out this service was using unobtrusive messages and it appears that nServiceBus.Testing isn’t aware of that and there doesn’t seem to be a way to make it aware.  Currently I’ve just added IMessage to my messages.

NServiceBus config errors

If you get an error about logging when starting a nservice bus service drill down on the exception to see what the real error is.