From 255dbb36031a55fd84ae02dff6f1b70beb8dac55 Mon Sep 17 00:00:00 2001 From: alex289 Date: Wed, 1 Jan 2025 16:10:44 +0100 Subject: [PATCH] fix: Create Connection for rabbit health check --- CleanArchitecture.Api/Program.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CleanArchitecture.Api/Program.cs b/CleanArchitecture.Api/Program.cs index 37a2c17..83b8246 100644 --- a/CleanArchitecture.Api/Program.cs +++ b/CleanArchitecture.Api/Program.cs @@ -1,3 +1,4 @@ +using System; using CleanArchitecture.Api.BackgroundServices; using CleanArchitecture.Api.Extensions; using CleanArchitecture.Application.Extensions; @@ -15,6 +16,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using RabbitMQ.Client; var builder = WebApplication.CreateBuilder(args); @@ -46,7 +48,14 @@ .AddSqlServer(dbConnectionString!) .AddRedis(redisConnectionString!, "Redis") .AddRabbitMQ( - rabbitConfiguration.ConnectionString, + async _ => + { + var factory = new ConnectionFactory + { + Uri = new Uri(rabbitConfiguration.ConnectionString), + }; + return await factory.CreateConnectionAsync(); + }, name: "RabbitMQ"); }