Open Closed

Rabbitmq health check #10489


User avatar
0
laura created

CAn I create an health check to verify the connection to rabbitmq


1 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • Yes. ABP doesn’t ship a RabbitMQ-specific health check out of the box, but you can add a standard ASP.NET Core health check (RabbitMQ) to your *.HttpApi.Host (and/or any service that must connect to RabbitMQ).
    1. Add the RabbitMQ health check NuGet package to the host project
    dotnet add package AspNetCore.HealthChecks.RabbitMQ
    
    1. Register the health check in your HttpApiHostModule
    using Microsoft.Extensions.DependencyInjection;
    using Volo.Abp.Modularity;
    
    public class MyProjectHttpApiHostModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            var configuration = context.Services.GetConfiguration();
    
            context.Services
                .AddHealthChecks()
                .AddRabbitMQ(
                    rabbitConnectionString: configuration.GetConnectionString("RabbitMQ"),
                    name: "rabbitmq",
                    timeout: TimeSpan.FromSeconds(5)
                );
        }
    }
    
    1. Expose the health endpoint in OnApplicationInitialization
    using Microsoft.AspNetCore.Builder;
    using Microsoft.Extensions.DependencyInjection;
    using Volo.Abp;
    
    public override void OnApplicationInitialization(ApplicationInitializationContext context)
    {
        var app = context.GetApplicationBuilder();
    
        app.UseConfiguredEndpoints(endpoints =>
        {
            endpoints.MapHealthChecks("/health");
        });
    }
    
    1. Configure the connection string (example)
    {
      "ConnectionStrings": {
        "RabbitMQ": "amqp://guest:guest@localhost:5672"
      }
    }
    

    Now GET /health will report RabbitMQ as Healthy/Unhealthy based on connectivity.

    • Sources:
      • https://www.nuget.org/packages/AspNetCore.HealthChecks.RabbitMQ
      • https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks
      • https://abp.io/community/articles/kwnjkun1

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.3.0-preview. Updated on March 02, 2026, 08:48
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.