0
0
mirror of https://github.com/alex289/CleanArchitecture.git synced 2025-06-30 18:42:56 +00:00

feat: Add health check for rabbitmq

This commit is contained in:
alex289 2023-09-02 12:22:31 +02:00
parent f44d36af02
commit 8ed703a865
No known key found for this signature in database
GPG Key ID: 573F77CD2D87F863
2 changed files with 10 additions and 1 deletions

View File

@ -8,6 +8,7 @@
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.ApplicationStatus" Version="7.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="7.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="7.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="7.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="7.1.0" />

View File

@ -30,10 +30,18 @@ builder.Services
if (builder.Environment.IsProduction())
{
var rabbitMqConfig = builder.Configuration.GetSection("RabbitMQ");
// Todo: Check if this works
var host = rabbitMqConfig["Host"]!;
var username = rabbitMqConfig["Username"]!;
var password = rabbitMqConfig["Password"]!;
builder.Services
.AddHealthChecks()
.AddSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")!)
.AddRedis(builder.Configuration["RedisHostName"]!, "Redis");
.AddRedis(builder.Configuration["RedisHostName"]!, "Redis")
.AddRabbitMQ($"amqp://{username}:{password}@{host}:5672", null, "RabbitMQ");
}
builder.Services.AddDbContext<ApplicationDbContext>(options =>