title: MassTransit implementation: sometimes message not received
body: <p>I am fighting with a quite strange problem... I have implemented a service bus communication (through MassTransit + MSMQ) between WCF services, with .NET 4.0 on Windows 7 Ultimate. When the services start up, everything works fine and they receive the message each other but, at a given point, they don't receive them anymore till I manually delete the Private Queues in Computer Management -> Services and Applications -> Message Queueing -> Private Queues.</p>
  
  <p>Per each service I have a bootstrapper where I configure out the MassTransit:</p>
  
  <pre><code>    // Bootstrapper configuration
      public void Configure(IUnityContainer container)
      {
          // Service bus configuration
          var config = ConfigurationDataAccess.GetSupervisionServiceConfig();
  
          // Cleaning up the former Private Queues before to start the service
          var privateQueues = MessageQueue.GetPrivateQueuesByMachine(System.Environment.MachineName);
  
          foreach (var messageQueue in privateQueues)
          {
              try
              {
                  if (messageQueue.QueueName.Contains("supervisionservice"))
                  {
                      MessageQueue.Delete(messageQueue.Path);
                  }
              }
              catch (MessageQueueException)
              {
                  // An exception has occurred trying to remove a private message queue.
              }
          }
  
          // Initializing MassTransit
          var bus = ServiceBusFactory.New(sbc =&gt;
          {
              sbc.UseMsmq();
              sbc.VerifyMsmqConfiguration();
              sbc.UseMulticastSubscriptionClient();
              sbc.ReceiveFrom(config.ServiceBusReceiveFromAddress);
          });
  
          container.RegisterInstance(bus);
  
          //Start the service...
      }
  }
  </code></pre>
  
  <p>Then the services main class extend the MassTransit, here an example:</p>
  
  <pre><code>[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
  public class DataService : Consumes&lt;ServiceMessage&gt;.Selected
  {
       public DataService()
       {
            // The service bus object takes the instance from the bootstrapper through the dependency
            // injection of the Unity.
            ServiceBus.SubscribeInstance(this);
       }
  
      public bool Accept(ServiceMessage message)
      {
          // For an easy explanation
          return true;
      }
  
      public void Consume(ServiceMessage message)
      {
          // Treat the message
      }
  
      public void SendMessage(ServiceMessage message)
      {
          // Publish the message over the service bus
          ServiceBus.Publish(message);
      }
  }
  </code></pre>
  
  <p>As I have explained, at a given point the Accept method is no more called. The only way is to delete manually the private queues and restart the services. Then the system works fine again, till the next trouble :-(.</p>
  
  <p>Any suggestions will be really appreciated. </p>
  
  <p>Many thanks!
  Alessandro</p>