title: How can i connnect `IConsumeMessageObserver` to the consumer, in the context of DI, using `AddMediator()` extension method, in MassTransit?
body: <p>I was faced with one diffucult, I havent idea how to add <code>IConsumeMessageObserver</code> entity in DI context, using <code>AddMediator()</code> extension method. In that section (<a href="https://masstransit-project.com/advanced/observers.html#received-messages" rel="nofollow noreferrer">https://masstransit-project.com/advanced/observers.html#received-messages</a>), only shows, how do it manually.</p>
  <p>I tried to resolve <code>IMediator</code> after <code>AddMediator()</code> call, like this:</p>
  <pre><code>private static void BindInMemoryBroker ( IServiceCollection services )
          {
              services.AddMediator ( configuration =&gt;
                {
                    AddInMemoryAddOnBroker ( configuration );
                } );
  
              var serviceProvider = services.BuildServiceProvider ();
  
              var mediator = serviceProvider.GetService&lt;IMediator&gt; ();
  
              var observer1 = serviceProvider.GetService&lt;MailingObserver&lt;RetrieveAddOnDownloadLinkContract&gt;&gt; ();
  
              var observer2 = serviceProvider.GetService&lt;IncrementAddOnDownloadCounterObserver&lt;RetrieveAddOnDownloadLinkContract&gt;&gt; ();
  
              mediator.ConnectConsumeMessageObserver ( observer1 );
  
              mediator.ConnectConsumeMessageObserver ( observer2 );
          }
  
          private static void AddInMemoryAddOnBroker ( IServiceCollectionMediatorConfigurator configuration )
          {
              AddInMemoryConsumers ( configuration );
  
              AddInMemoryContracts ( configuration );
          }
  
          private static void AddInMemoryConsumers ( IServiceCollectionMediatorConfigurator configuration )
          {
  
              configuration.AddConsumer&lt;RetrieveAddOnDownloadLinkConsumer&gt; ();
  
          }
  
          private static void AddInMemoryContracts ( IServiceCollectionMediatorConfigurator configuration )
          {
              configuration.AddRequestClient&lt;RetrieveAddOnDownloadLinkContract&gt; ();
          }
  </code></pre>
  <p>But it didn't work, pls help me</p>