Skip to content

amqpx v1.0.1


amqpx / index / ExchangeImplementation

Class: ExchangeImplementation

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

Implements

Constructors

Constructor

new ExchangeImplementation(channel, exchangeName, exchangeType, options?): ExchangeImplementation

Defined in: src/exchange/exchange-implementation.ts:22

Parameters

ParameterType
channelChannel
exchangeNamestring
exchangeTypestring
options?ExchangeOptions

Returns

ExchangeImplementation

Properties

PropertyModifierTypeDefined in
channelreadonlyChannelsrc/exchange/exchange-implementation.ts:23

Methods

assert()

assert(): Promise<ExchangeImplementation>

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

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

Implementation of

Exchange.assert


bindExchange()

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

Defined in: src/exchange/exchange-implementation.ts:99

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

Implementation of

Exchange.bindExchange


bindQueue()

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

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

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

Implementation of

Exchange.bindQueue


createBatchConsumer()

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

Defined in: src/exchange/exchange-implementation.ts:155

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

Returns

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

Implementation of

Exchange.createBatchConsumer


createConsumer()

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

Defined in: src/exchange/exchange-implementation.ts:145

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

Returns

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

Implementation of

Exchange.createConsumer


createProducer()

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

Defined in: src/exchange/exchange-implementation.ts:165

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

Implementation of

Exchange.createProducer


name()

name(): Promise<string>

Defined in: src/exchange/exchange-implementation.ts:67

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

Returns

Promise<string>

Implementation of

Exchange.name

Released under the MIT License.