Rabbit Relay

Health Checks

Runtime health information through broker.health() for readiness endpoints, dashboards, and debugging.

Rabbit Relay exposes runtime health information through broker.health().

This is useful for service readiness endpoints, dashboards, and debugging.


Basic usage

const health = await broker.health();

console.log(health);

Example response:

{
  peerName: "orders-service",
  connected: true,
  channelOpen: true,
  confirmChannelOpen: true,
  reconnecting: false,
  consumers: [
    {
      queue: "orders.q",
      active: true,
      prefetch: 20,
      concurrency: 5,
      activeHandlers: 2,
      pendingMessages: 8,
      onError: "retry",
      retry: {
        attempts: 3,
        then: "dead-letter",
        delayMs: 5000
      }
    }
  ]
}

Express endpoint example

app.get("/health/rabbitmq", async (_req, res) => {
  const health = await broker.health();

  if (!health.connected || !health.channelOpen || health.reconnecting) {
    return res.status(503).json(health);
  }

  return res.json(health);
});

Consumer state

Health output includes each registered consumer:

FieldMeaning
queueQueue name
activeWhether consuming is active
prefetchRabbitMQ prefetch value
concurrencyMax handler concurrency
activeHandlersCurrently running handlers
pendingMessagesDelivered messages waiting in memory
onErrorError policy
retryRetry policy, if enabled

Health is runtime status.

For deeper operations visibility, use:


Best-effort status

amqplib does not expose a perfect public isOpen() API for channels and connections.

Rabbit Relay combines its own reconnect state with best-effort checks to report health.

Use this for:

  • readiness checks
  • debugging
  • dashboards
  • operational visibility

Summary

  • broker.health() returns connection and consumer state
  • Useful for APIs and service readiness
  • Includes concurrency, retry, delay, and pending-message info
  • Health state is best-effort and operationally useful

On this page