title: NServiceBus: Messages handled multiple times
body: <p>I am at a complete loss as to why I am experiencing this problem. I am new to NServiceBus and have so far set up a dead simple 'server' which listens for messages sent by a web application. The server asks for custom initialisation (IWantCustomInitialization) and uses a <a href="http://blog.paulhadfield.net/2010/09/updating-nservicebus-to-use-another.html" rel="nofollow noreferrer">custom builder for Castle Windsor 2.5.1</a>. This custom builder is basically a copy of the one that comes with the NServiceBus source code, with two minor changes to move away from methods deprecated in Windsor 2.5.</p>
  
  <p>Note that my code shares the container instance with NServiceBus.</p>
  
  <p>The problem I experience is that every message sent by the web application is processed five (5) times by the server. The log files have five entries for each attempt, with the fifth attempt looking like this:</p>
  
  <pre><code>2011-03-28 16:04:10,326 [Worker.8] DEBUG NServiceBus.Unicast.UnicastBus [] - Calling 'HandleEndMessage' on NServiceBus.SagaPersisters.NHibernate.NHibernateMessageModule
  2011-03-28 16:04:10,327 [Worker.8] DEBUG NServiceBus.Unicast.UnicastBus [] - Calling 'HandleEndMessage' on Server.NHibernateSessionMessageModule
  2011-03-28 16:04:10,341 [Worker.8] DEBUG NServiceBus.Unicast.UnicastBus [] - Calling 'HandleError' on NServiceBus.SagaPersisters.NHibernate.NHibernateMessageModule
  2011-03-28 16:04:10,342 [Worker.8] DEBUG NServiceBus.Unicast.UnicastBus [] - Calling 'HandleError' on Server.NHibernateSessionMessageModule
  2011-03-28 16:04:10,344 [Worker.8] ERROR NServiceBus.Unicast.Transport.Msmq.MsmqTransport [] - Message has failed the maximum number of times allowed, ID=80cffd98-a5bd-43e0-a482-a2d96ca42b22\20677.
  </code></pre>
  
  <p>I have <em>no</em> indication why the message fails, and I don't know where to dig for more information/output.</p>
  
  <p>The configuration 'endpoint' looks like this:</p>
  
  <pre><code>public void Init()
  {
      container = Windsor.Container;
      NServiceBus.Configure.With().CastleWindsor251Builder(container).XmlSerializer().MsmqTransport().IsolationLevel(System.Transactions.IsolationLevel.Unspecified);
  
      var masterInstaller = new NotificationServerInstaller();
      masterInstaller.Install(container, null);
  }
  </code></pre>
  
  <p>The message handler is, at this stage, really contrived, and looks like this:</p>
  
  <pre><code>public class NewUserMessageHandler : IHandleMessages&lt;NotifyNewUserMessage&gt;
  {
      private readonly IGetUserQuery _getUserQuery;
  
      public NewUserMessageHandler(IGetUserQuery getUserQuery)
      {
          _getUserQuery = getUserQuery;
      }
  
      public void Handle(NotifyNewUserMessage message)
      {
          var result = _getUserQuery.Invoke(new GetUserRequest { Id = new Guid("C10D0684-D25F-4E5E-A347-16F85DB7BFBF") });
          Console.WriteLine("New message received: {0}", message.UserSystemId);
      }
  }
  </code></pre>
  
  <p>If the first line in the handler method is commented out, the message is processed only once.</p>
  
  <p>I have found some posts/threads on the web (including StackOverflow) which talk about similar issues, notably <a href="http://tech.groups.yahoo.com/group/nservicebus/message/5977" rel="nofollow noreferrer">http://tech.groups.yahoo.com/group/nservicebus/message/5977</a> and <a href="https://stackoverflow.com/questions/2406340/anyone-using-ninject-2-0-as-the-nservicebus-objectbuilder/2410105">Anyone using Ninject 2.0 as the nServiceBus ObjectBuilder?</a> - but I haven't had any success in making my problem go away.</p>
  
  <p>I'd be most obliged for any help. I'm a n00b at NServiceBus!</p>