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
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
| Parameter | Type | Description |
|---|---|---|
name | string | Queue 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
| Parameter | Type | Description |
|---|---|---|
timeout? | number | Maximum 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
| 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 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
| 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>>>
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
| 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 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
| Parameter | Type | Description |
|---|---|---|
queue | Queue | Source 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
| Parameter | Type | Description |
|---|---|---|
name | string | Exchange name. |
type | string | Exchange type (direct, fanout, topic, headers, …). |
options? | ExchangeOptions | Optional 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
| Parameter | Type | Description |
|---|---|---|
exchange | Exchange | Target 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
| Parameter | Type | Description |
|---|---|---|
queue | Queue | Target 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
| Parameter | Type | Description |
|---|---|---|
name | string | Queue name. |
options? | QueueOptions | Optional 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
| Parameter | Type | Description |
|---|---|---|
exchange | string | Exchange name to publish to. |
routingKey | string | Routing key for the message. |
content | Buffer | Serialized message body. |
options | ChannelPublishOptions | Publish 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).