title: EasyNetQ (AMQP) Single Application Connection In ASP.NET?
body: <p>Community:</p>
  
  <p>I'm struggling to figure out how to create a single AMQP connection that lives with my ASP.NET application lifecycle in ASP.NET using .NET Core 2.1. After researching, I've found lots of references to using a single AMQP connection for the whole application as they are expensive and slow to create and I was headed down the road of creating the connection using DI but it appears my approach is flawed, I can't seem to identify which interface I need to add as a singleton...</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
          {
              var sqlConnectionStringBuilder = new SqlConnectionStringBuilder(Configuration.GetConnectionString("DefaultConnection"));
              var envSQL = Environment.GetEnvironmentVariable("ASPNETCORE_SQL_SERVER");
              if (envSQL != null)
                  sqlConnectionStringBuilder.DataSource = envSQL;
  
              services.AddSingleton&lt;IMessageBusService, MessageBusService&gt;();
              services.AddSingleton&lt;EasyNetQ.IAdvancedBus, RabbitAdvancedBus&gt;();
              services.AddSingleton&lt;EasyNetQ.IConnectionFactory, ConnectionFactoryWrapper&gt;();
  
              services.AddMvc();
  
          }
  </code></pre>
  
  <p>Adding the above interfaces works but I get an error about ConnectionConfiguration service not being locatable. Is this the right direction or is there a more proper  way to create a single application once EasyNetQ connection in ASP.NET core? </p>