Skip to content

amqpx v1.0.1


amqpx / index / Channel

Interface: Channel ​

Defined in: src/channel/channel.ts:36

Extends ​

  • EventEmitter<ChannelEventMap>

Accessors ​

connection ​

Get Signature ​

get connection(): Connection

Defined in: src/channel/channel.ts:41

The Connection that owns this channel.

Returns ​

Connection

Methods ​

checkQueue() ​

checkQueue(name): Promise<AssertQueue>

Defined in: src/channel/channel.ts:81

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>


close() ​

close(timeout?): Promise<void>

Defined in: src/channel/channel.ts:56

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

Parameters ​

ParameterTypeDescription
timeout?numberMaximum milliseconds to wait for pending confirmations before closing. Throws 'Channel close timed out' if exceeded. Waits 30s when omitted.

Returns ​

Promise<void>


connect() ​

connect(): Promise<Channel>

Defined in: src/channel/channel.ts:48

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<Channel>


createBatchConsumerForExchange() ​

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

Defined in: src/channel/channel.ts:171

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>>>


createBatchConsumerForQueue() ​

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

Defined in: src/channel/channel.ts:158

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>>>


createConsumerForExchange() ​

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

Defined in: src/channel/channel.ts:147

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>>>


createConsumerForQueue() ​

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

Defined in: src/channel/channel.ts:134

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>>>


createExchange() ​

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

Defined in: src/channel/channel.ts:65

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>


createProducerForExchange() ​

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

Defined in: src/channel/channel.ts:123

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.
options?ProducerOptions<T>Optional producer options (serialization, routing key, hooks, …).

Returns ​

Promise<Producer<T, T>>


createProducerForQueue() ​

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

Defined in: src/channel/channel.ts:112

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.
options?ProducerOptions<T>Optional producer options (serialization, routing key, hooks, …).

Returns ​

Promise<Producer<T, T>>


createQueue() ​

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

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

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

Parameters ​

ParameterTypeDescription
namestringQueue name.
options?QueueOptionsOptional queue assertion options.

Returns ​

Promise<Queue>


native() ​

native(): Promise<Channel | ConfirmChannel>

Defined in: src/channel/channel.ts:87

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

Returns ​

Promise<Channel | ConfirmChannel>


publish() ​

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

Defined in: src/channel/channel.ts:101

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.
optionsChannelPublishOptionsPublish options including drain timeout and retry strategy.

Returns ​

Promise<boolean>

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

Released under the MIT License.