diff --git a/JOBot.Backend/Startup.cs b/JOBot.Backend/Startup.cs index 3c6c2ab..38366f5 100644 --- a/JOBot.Backend/Startup.cs +++ b/JOBot.Backend/Startup.cs @@ -22,18 +22,22 @@ public class Startup(IConfiguration configuration) services.AddDbContext(options => options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL"))); - var rabbitMqConnection = new ConnectionFactory + + services.AddSingleton(x => { - HostName = "rabbitmq" - }.CreateConnectionAsync().Result; - var channel = rabbitMqConnection.CreateChannelAsync().Result; - channel.QueueDeclareAsync( - RabbitQueues.AuthQueue, - false, - false, - false, - arguments: null).Wait(); - services.AddSingleton(channel); + var rabbitMqConnection = new ConnectionFactory + { + HostName = "rabbitmq" + }.CreateConnectionAsync().Result; + var channel = rabbitMqConnection.CreateChannelAsync().Result; + channel.QueueDeclareAsync( + RabbitQueues.AuthQueue, + false, + false, + false, + arguments: null).Wait(); + return channel; + }); services.Configure(Configuration.GetSection(HeadHunterConfig.SectionName));