amqpx / index / ConnectionImplementation
Class: ConnectionImplementation
Defined in: src/connection/connection-implementation.ts:18
Extends
EventEmitter<ConnectionEventMap>
Implements
Constructors
Constructor
new ConnectionImplementation(
options,retryStrategy?,socketOptions?):ConnectionImplementation
Defined in: src/connection/connection-implementation.ts:24
Parameters
| Parameter | Type |
|---|---|
options | Connect |
retryStrategy | RetryStrategy |
socketOptions? | unknown |
Returns
ConnectionImplementation
Overrides
EventEmitter<ConnectionEventMap>.constructor
Methods
close()
close(
timeout?):Promise<void>
Defined in: src/connection/connection-implementation.ts:98
Gracefully closes the connection. Emits the close event after the underlying amqplib connection is fully shut down. Has no effect if the connection is in preconnect or closed state.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
timeout | number | 30_000 | Maximum milliseconds to wait for the underlying connection to close. Throws 'Connection close timed out' if exceeded. Waits 30s when omitted. |
Returns
Promise<void>
Implementation of
connect()
connect():
Promise<ConnectionImplementation>
Defined in: src/connection/connection-implementation.ts:36
Establishes the connection. Safe to call concurrently — multiple callers will share the same attempt. After retries are exhausted (ConnectionEventMap.connectionRetryExhausted), the connection moves to the closed state, but connect() may be called again to start a fresh connection attempt.
Returns
Promise<ConnectionImplementation>
Implementation of
createBatchConsumerForExchange()
createBatchConsumerForExchange<
T>(exchange,options,queueOptions?):Promise<BatchConsumer<T,Record<string,unknown>>>
Defined in: src/connection/connection-implementation.ts:160
Creates a batch consumer for an exchange and opens a dedicated channel for it. Internally asserts an exclusive queue and binds it to the exchange.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
exchange | Exchange | Source exchange. |
options | ExchangeBatchConsumerOptions<T> | Batch consumer options, including the binding pattern. |
queueOptions? | ExchangeConsumerQueueOptions | Options for the auto-created exclusive queue. |
Returns
Promise<BatchConsumer<T, Record<string, unknown>>>
Implementation of
Connection.createBatchConsumerForExchange
createBatchConsumerForQueue()
createBatchConsumerForQueue<
T>(queue,options?):Promise<BatchConsumer<T,Record<string,unknown>>>
Defined in: src/connection/connection-implementation.ts:156
Creates a batch consumer for a queue and opens a dedicated channel for it.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
queue | Queue | Source queue. |
options? | BatchConsumerOptions<T> | Optional batch consumer options (batch size, failure strategy, prefetch, …). |
Returns
Promise<BatchConsumer<T, Record<string, unknown>>>
Implementation of
Connection.createBatchConsumerForQueue
createChannel()
createChannel(
isConfirmed?):Channel
Defined in: src/connection/connection-implementation.ts:144
Creates a new channel on this connection.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
isConfirmed | boolean | false | If true, creates a confirm channel (publisher confirms enabled). |
Returns
Implementation of
createConsumerForExchange()
createConsumerForExchange<
T>(exchange,options,queueOptions?):Promise<Consumer<T,Record<string,unknown>>>
Defined in: src/connection/connection-implementation.ts:148
Creates a consumer for an exchange and opens a dedicated channel for it. Internally asserts an exclusive queue and binds it to the exchange.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
exchange | Exchange | Source exchange. |
options | ExchangeConsumerOptions<T> | Consumer options, including the binding pattern. |
queueOptions? | ExchangeConsumerQueueOptions | Options for the auto-created exclusive queue. |
Returns
Promise<Consumer<T, Record<string, unknown>>>
Implementation of
Connection.createConsumerForExchange
createConsumerForQueue()
createConsumerForQueue<
T>(queue,options?):Promise<Consumer<T,Record<string,unknown>>>
Defined in: src/connection/connection-implementation.ts:152
Creates a consumer for a queue and opens a dedicated channel for it.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
queue | Queue | Source queue. |
options? | ConsumerOptions<T> | Optional consumer options (failure strategy, prefetch, …). |
Returns
Promise<Consumer<T, Record<string, unknown>>>
Implementation of
Connection.createConsumerForQueue
createProducerForExchange()
createProducerForExchange<
T>(exchange,options?,isConfirmed?):Promise<Producer<T,T>>
Defined in: src/connection/connection-implementation.ts:164
Creates a producer for an exchange and opens a dedicated channel for it.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
exchange | Exchange | Target exchange. |
options? | ProducerOptions<T> | Optional producer options (serialization, routing key, hooks, …). |
isConfirmed? | boolean | If true, the dedicated channel uses publisher confirms. |
Returns
Promise<Producer<T, T>>
Implementation of
Connection.createProducerForExchange
createProducerForQueue()
createProducerForQueue<
T>(queue,options?,isConfirmed?):Promise<Producer<T,T>>
Defined in: src/connection/connection-implementation.ts:168
Creates a producer for a queue and opens a dedicated channel for it.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
queue | Queue | Target queue. |
options? | ProducerOptions<T> | Optional producer options (serialization, routing key, hooks, …). |
isConfirmed? | boolean | If true, the dedicated channel uses publisher confirms. |
Returns
Promise<Producer<T, T>>
Implementation of
Connection.createProducerForQueue
native()
native():
Promise<ChannelModel>
Defined in: src/connection/connection-implementation.ts:134
Returns the underlying amqplib connection. Resolves once the connection is established. This is intended for internal use.
Returns
Promise<ChannelModel>
Implementation of
state()
state():
ConnectionState
Defined in: src/connection/connection-implementation.ts:130
Returns the current state of the connection.