Skip to content

amqpx v1.0.1


amqpx / index / RabbitCloser

Class: RabbitCloser

Defined in: src/graceful-shutdown/rabbit-closer.ts:14

Orchestrates an orderly shutdown of all registered producers, consumers, channels, and connections.

Shutdown order: producers → consumers → channels → connections.

Constructors

Constructor

new RabbitCloser(connections, consumers, producers): RabbitCloser

Defined in: src/graceful-shutdown/rabbit-closer.ts:20

Parameters

ParameterTypeDescription
connectionsConnection[]Connections to close after all producers and consumers have stopped.
consumers(Consumer<unknown, Record<string, unknown>> | BatchConsumer<unknown, Record<string, unknown>>)[]Consumers to stop before closing channels and connections.
producersProducer<unknown, unknown>[]Producers to stop first, waiting for all pending publishes to settle.

Returns

RabbitCloser

Methods

close()

close(timeout?): Promise<void>

Defined in: src/graceful-shutdown/rabbit-closer.ts:36

Performs the orderly shutdown sequence with an optional overall timeout budget. Each stage receives the remaining milliseconds at the moment it starts, so later stages (channels, connections) get progressively less time than earlier ones. Waits for each stage to complete before proceeding to the next. Follows sequence: producers → consumers → channels → connections.

Parameters

ParameterTypeDefault valueDescription
timeoutnumber60_000Total budget in milliseconds for the entire shutdown sequence. When omitted, each stage waits indefinitely.

Returns

Promise<void>

Released under the MIT License.