Skip to content

amqpx v1.0.1


amqpx / index / ChannelImplementation

Class: ChannelImplementation

Defined in: src/channel/channel-implementation.ts:19

Extends

  • EventEmitter<ChannelEventMap>

Implements

Constructors

Constructor

new ChannelImplementation(connection, publishConfirm): ChannelImplementation

Defined in: src/channel/channel-implementation.ts:24

Parameters

ParameterType
connectionConnection
publishConfirmboolean

Returns

ChannelImplementation

Overrides

EventEmitter<ChannelEventMap>.constructor

Properties

PropertyModifierTypeDefined in
connectionreadonlyConnectionsrc/channel/channel-implementation.ts:25

Methods

checkQueue()

checkQueue(name): Promise<AssertQueue>

Defined in: src/channel/channel-implementation.ts:121

Check whether a queue exists on the broker without asserting it. Resolves with queue metadata; rejects if the queue does not exist.

Parameters

ParameterTypeDescription
namestringQueue name to inspect.

Returns

Promise<AssertQueue>

Implementation of

Channel.checkQueue


close()

close(timeout?): Promise<void>

Defined in: src/channel/channel-implementation.ts:73

Close the underlying amqplib channel. For confirm channels, waits for all pending confirmations before closing.

Parameters

ParameterTypeDefault valueDescription
timeoutnumber30_000Maximum milliseconds to wait for pending confirmations before closing. Throws 'Channel close timed out' if exceeded. Waits 30s when omitted.

Returns

Promise<void>

Implementation of

Channel.close


connect()

connect(): Promise<ChannelImplementation>

Defined in: src/channel/channel-implementation.ts:35

Open the underlying amqplib channel. Must be called before any other operation. Subsequent calls are no-ops if the channel is already open.

Returns

Promise<ChannelImplementation>

Implementation of

Channel.connect


createBatchConsumerForExchange()

createBatchConsumerForExchange<T>(exchange, options, queueOptions?): Promise<BatchConsumer<T, Record<string, unknown>>>

Defined in: src/channel/channel-implementation.ts:226

Create a batch consumer that reads from an exchange using this channel. Internally asserts an exclusive queue and binds it to the exchange. Each consumer should have its own dedicated channel; this method uses the current channel. Consider using connection.createBatchConsumerForExchange or pass a channel in options param.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
exchangeExchangeSource exchange.
optionsExchangeBatchConsumerOptions<T>Batch consumer options including the binding pattern.
queueOptions?ExchangeConsumerQueueOptionsOptions for the auto-created exclusive queue binding.

Returns

Promise<BatchConsumer<T, Record<string, unknown>>>

Implementation of

Channel.createBatchConsumerForExchange


createBatchConsumerForQueue()

createBatchConsumerForQueue<T>(queue, options?): Promise<BatchConsumer<T, Record<string, unknown>>>

Defined in: src/channel/channel-implementation.ts:219

Create a batch consumer that reads from a queue using this channel. Each consumer should have its own dedicated channel; this method uses the current channel. Consider using connection.createBatchConsumerForQueue or pass a channel in options param.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
queueQueueSource queue.
options?BatchConsumerOptions<T>Optional batch consumer options (batch size, failure strategy, prefetch, …).

Returns

Promise<BatchConsumer<T, Record<string, unknown>>>

Implementation of

Channel.createBatchConsumerForQueue


createConsumerForExchange()

createConsumerForExchange<T>(exchange, options, queueOptions?): Promise<Consumer<T, Record<string, unknown>>>

Defined in: src/channel/channel-implementation.ts:212

Create a consumer that reads from an exchange using this channel. Internally asserts an exclusive queue and binds it to the exchange. Each consumer should have its own dedicated channel; this method uses the current channel. Consider using connection.createConsumerForExchange or pass a channel in options param.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
exchangeExchangeSource exchange.
optionsExchangeConsumerOptions<T>Consumer options including the binding pattern.
queueOptions?ExchangeConsumerQueueOptionsOptions for the auto-created exclusive queue binding.

Returns

Promise<Consumer<T, Record<string, unknown>>>

Implementation of

Channel.createConsumerForExchange


createConsumerForQueue()

createConsumerForQueue<T>(queue, options?): Promise<Consumer<T, Record<string, unknown>>>

Defined in: src/channel/channel-implementation.ts:205

Create a consumer that reads from a queue using this channel. Each consumer should have its own dedicated channel; this method uses the current channel. Consider using connection.createConsumerForQueue or pass a channel in options param.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
queueQueueSource queue.
options?ConsumerOptions<T>Optional consumer options (failure strategy, prefetch, …).

Returns

Promise<Consumer<T, Record<string, unknown>>>

Implementation of

Channel.createConsumerForQueue


createExchange()

createExchange(name, type, options?): Promise<Exchange>

Defined in: src/channel/channel-implementation.ts:113

Assert an exchange on the broker and return an Exchange handle.

Parameters

ParameterTypeDescription
namestringExchange name.
typestringExchange type (direct, fanout, topic, headers, …).
options?ExchangeOptionsOptional exchange assertion options.

Returns

Promise<Exchange>

Implementation of

Channel.createExchange


createProducerForExchange()

createProducerForExchange<T>(exchange, options?): Promise<Producer<T, T>>

Defined in: src/channel/channel-implementation.ts:198

Create a producer that publishes to an exchange using this channel. Each producer should have its own dedicated channel; this method uses the current channel. Consider using connection.createProducerForExchange or pass a channel in options param.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
exchangeExchangeTarget exchange.
optionsProducerOptions<T>Optional producer options (serialization, routing key, hooks, …).

Returns

Promise<Producer<T, T>>

Implementation of

Channel.createProducerForExchange


createProducerForQueue()

createProducerForQueue<T>(queue, options?): Promise<Producer<T, T>>

Defined in: src/channel/channel-implementation.ts:191

Create a producer that publishes directly to a queue using this channel. Each producer should have its own dedicated channel; this method uses the current channel. Consider using connection.createProducerForQueue or pass a channel in options param.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
queueQueueTarget queue.
optionsProducerOptions<T>Optional producer options (serialization, routing key, hooks, …).

Returns

Promise<Producer<T, T>>

Implementation of

Channel.createProducerForQueue


createQueue()

createQueue(name, options?): Promise<Queue>

Defined in: src/channel/channel-implementation.ts:117

Assert a queue on the broker and return a Queue handle.

Parameters

ParameterTypeDescription
namestringQueue name.
options?QueueOptionsOptional queue assertion options.

Returns

Promise<Queue>

Implementation of

Channel.createQueue


native()

native(): Promise<Channel | ConfirmChannel>

Defined in: src/channel/channel-implementation.ts:126

Returns the underlying amqplib channel, connecting first if not already open. This is intended for internal use.

Returns

Promise<Channel | ConfirmChannel>

Implementation of

Channel.native


publish()

publish(exchange, routingKey, content, optionsArgs): Promise<boolean>

Defined in: src/channel/channel-implementation.ts:133

Publish message directly using amqplib publish function. Handles backpressure (drain) and confirm-channel retries automatically. This is intended for internal use. Use createProducer* functions instead.

Parameters

ParameterTypeDescription
exchangestringExchange name to publish to.
routingKeystringRouting key for the message.
contentBufferSerialized message body.
optionsArgsChannelPublishOptions-

Returns

Promise<boolean>

true if the broker confirmed receipt (confirm channel), false if fire-and-forget (non-confirm channel).

Implementation of

Channel.publish

Released under the MIT License.