Connectum API Reference / @connectum/events-amqp / types / AmqpLifecycleEvent
Type Alias: AmqpLifecycleEvent
AmqpLifecycleEvent = {
reconnected:boolean;type:"connected"; } | {error:Error;type:"disconnected"; } | {attempt:number;delay:number;error:Error;type:"reconnecting"; } | {error:Error;type:"reconnect-failed"; } | {attempt:number;error:Error;initial:boolean;type:"setup-failed"; } | {reason:string;type:"blocked"; } | {type:"unblocked"; }
Defined in: packages/events-amqp/src/types.ts:446
Discriminated connection lifecycle event, delivered to AmqpLifecycleCallbacks.onLifecycle.
Exactly-once guarantees (pinned by integration tests):
connectedfires once per successful (re)connect;reconnectedisfalsefor the initial connect andtrueafter a recovery.disconnectedfires once per connection loss (a socket-level cut no longer double-fires via the rawerrorevent — fixed in 1.3.0).reconnectingfires once per scheduled retry — after the connection has been established once, and also per attempt of the bounded initial phase when AmqpRecoveryOptions.initialConnectMaxRetries is set.reconnect-failedis terminal and fires for any of its three triggers: the retry budget is exhausted (maxRetries), the fatal topology policy stopped the cycle (treatTopologyErrorAsFatal), or the initial connect budget ran out (initialConnectMaxRetries).setup-failedreports a topology/setup failure withinitial: truefor the startup window (attempt: 0on the probe; the 0-based attempt index in the bounded initial phase) orinitial: falsefor a reconnect re-assert (attempt>= 1).blocked/unblockedsurface broker flow control (RabbitMQconnection.blocked, e.g. under a memory/disk alarm); they have no flat callback equivalent.
Scope: with amqplib's own initial loop (default), the retry loop of the INITIAL connect (broker unreachable when connect() is called) happens before the lifecycle wiring can attach, so its per-retry events are not surfaced; the startup probe covers the deterministic-misconfiguration case (setup-failed { initial: true }). Set AmqpRecoveryOptions.initialConnectMaxRetries (since 1.3.0) to make the adapter own that window — its bounded phase surfaces per-attempt reconnecting/setup-failed events and a terminal reconnect-failed on budget exhaustion.
The type values are deliberately broker-agnostic so a future cross-adapter generalization stays non-breaking.
