fix: fixed migration by lazy load of rabbitmq

This commit is contained in:
Pavel-Savely Savianok 2025-07-25 19:43:14 +03:00
parent 17cec6dd64
commit 176cf194cd

View File

@ -22,18 +22,22 @@ public class Startup(IConfiguration configuration)
services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
var rabbitMqConnection = new ConnectionFactory
services.AddSingleton<IChannel>(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<HeadHunterConfig>(Configuration.GetSection(HeadHunterConfig.SectionName));