Skip to content

amqpx v1.0.1


amqpx / index / Exchange

Interface: Exchange

Defined in: src/exchange/exchange.ts:6

Methods

assert()

assert(): Promise<Exchange>

Defined in: src/exchange/exchange.ts:17

Verify the exchange against the broker, according to the configured assertionMode.

  • Assert (default) — declare the exchange; creates it if absent, throws on config mismatch.
  • Check — verify the exchange exists without creating it; throws if absent.
  • Passive — no-op; no network call is made.

Subsequent calls return immediately once the first call completes successfully. Returns this to allow chaining.

Returns

Promise<Exchange>


bindExchange()

bindExchange(exchange, pattern, args?): Promise<Exchange>

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

Bind another exchange to this exchange. Asserts the exchange first if it has not been asserted yet.

Parameters

ParameterTypeDescription
exchangeExchangeExchange to bind to this exchange.
patternstringRouting key pattern under which to bind.
args?BindingArgsOptional AMQP headers or x-arguments for the binding.

Returns

Promise<Exchange>


bindQueue()

bindQueue(queue, pattern, args?): Promise<Exchange>

Defined in: src/exchange/exchange.ts:32

Bind a queue to this exchange. Asserts the exchange first if it has not been asserted yet.

Parameters

ParameterTypeDescription
queueQueueQueue to bind to this exchange.
patternstringRouting key pattern under which to bind.
args?BindingArgsOptional AMQP headers or x-arguments for the binding.

Returns

Promise<Exchange>


createBatchConsumer()

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

Defined in: src/exchange/exchange.ts:59

Creates a batch consumer for the current exchange. Internally asserts an exclusive queue and binds it to the exchange. Unless specified otherwise, uses the same channel as was used to declare the exchange. This is generally not recommended, as each consumer should have its own dedicated channel. Consider using connection.createBatchConsumerForExchange instead.

Type Parameters

Type Parameter
T

Parameters

ParameterType
optionsExchangeBatchConsumerOptions<T>
queueOptions?ExchangeConsumerQueueOptions

Returns

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


createConsumer()

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

Defined in: src/exchange/exchange.ts:50

Creates a consumer for the current exchange. Internally asserts an exclusive queue and binds it to the exchange. Unless specified otherwise, uses the same channel as was used to declare the exchange. This is generally not recommended, as each consumer should have its own dedicated channel. Consider using connection.createConsumerForExchange instead.

Type Parameters

Type Parameter
T

Parameters

ParameterType
optionsExchangeConsumerOptions<T>
queueOptions?ExchangeConsumerQueueOptions

Returns

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


createProducer()

createProducer<T>(options?): Promise<Producer<T, T>>

Defined in: src/exchange/exchange.ts:71

Creates a producer for the current exchange. Unless specified otherwise, uses the same channel as was used to declare the exchange. This is generally not recommended, as each producer should have its own dedicated channel. Consider using connection.createProducerForExchange instead.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
options?ProducerOptions<T> & objectOptional producer options (serialization, routing key, hooks, …). Set options.isConfirmed to true to open the dedicated channel in confirm mode. Has no effect when options.channel is supplied.

Returns

Promise<Producer<T, T>>


name()

name(): Promise<string>

Defined in: src/exchange/exchange.ts:23

Returns the name of the exchange. Asserts the exchange first if it has not been asserted yet.

Returns

Promise<string>

Released under the MIT License.