title: MassTransit: How to stop the bus after all messages are consumed by consumer?
body: <p>I attempt to stop the bus after all the messages in queue consumed using MassTransit. And I set the concurrent Message limit to 1 as my consumer needs to process one message at a time. </p>
  
  <p>I've tried putting the bus.StopAsync() behind bus.StartAsync like below. And the result showed that after one message being consumed, the bus will stop.</p>
  
  <p>Bus configuration:</p>
  
  <pre><code>IBusControl bus = Bus.Factory.CreateUsingRabbitMq(cfg =&gt;
              {
                  IRabbitMqHost host = cfg.Host(new Uri("rabbitmq://localhost"), hostConfigurator =&gt;
                  {
                      hostConfigurator.Username("username");
                      hostConfigurator.Password("password");
                  });
  
              cfg.ReceiveEndpoint(host, "MyResult", ep =&gt;
              {
                  ep.Bind("MyExchange", s =&gt; { s.Durable = true; });
  
                  ep.Consumer&lt;MessageConsumer&gt;(mc =&gt;
                  {
                      mc.UseConcurrentMessageLimit(1);
                  });
              });
          });
  </code></pre>
  
  <p>Bus start and stop:</p>
  
  <pre><code>await bus.StartAsync();
  
  await bus.StopAsync();
  </code></pre>
  
  <p>My question is how to stop the bus after all messages in queue have been consumed. I am quite new to MassTransit, and really curious about the sequence of invoking consumers and stopping bus. Appreciate if someone could help. Thanks.</p>