Skip to content

API reference / @node-ts/bus-rabbitmq / RabbitMqTransport

Class: RabbitMqTransport ​

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:79

A RabbitMQ transport adapter for @node-ts/bus.

If the connection or channel to the broker is lost, the transport reconnects with backoff (see connectionRecovery in RabbitMqTransportConfiguration), re-declares its topology and resumes consuming. Publishing and sending wait for the reconnect. Messages that were received on the lost channel can no longer be acked, so the broker redelivers them.

Implements ​

Constructors ​

Constructor ​

ts
new RabbitMqTransport(configuration): RabbitMqTransport;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:117

Parameters ​

ParameterType
configurationRabbitMqTransportConfiguration

Returns ​

RabbitMqTransport

Methods ​

connect() ​

ts
connect(options): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:138

An optional function that will be called on startup. This gives a chance for the transport to establish any connections to the underlying infrastructure.

Parameters ​

ParameterType
optionsTransportConnectionOptions

Returns ​

Promise<void>

Implementation of ​

Transport.connect


deleteMessage() ​

ts
deleteMessage(message): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:336

Removes a message from the underlying transport. This will be called once a message has been successfully handled by any of the message handling functions.

Parameters ​

ParameterTypeDescription
messageTransportMessage<Message>The message to be removed from the transport

Returns ​

Promise<void>

Implementation of ​

Transport.deleteMessage


disconnect() ​

ts
disconnect(): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:161

An optional function that will be called on shutdown. This gives a chance for the transport to close any connections to the underlying infrastructure.

Returns ​

Promise<void>

Implementation of ​

Transport.disconnect


fail() ​

ts
fail(transportMessage): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:184

Forwards

Parameters ​

ParameterTypeDescription
transportMessageTransportMessage<unknown>to the dead letter queue. The message must have been read in from the queue and have a receipt handle.

Returns ​

Promise<void>

Implementation of ​

Transport.fail


initialize() ​

ts
initialize(): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:153

An optional function that will be called when the service bus is starting. This is an opportunity for the transport to see what messages need to be handled so that subscriptions to the topics can be created.

Returns ​

Promise<void>

Implementation of ​

Transport.initialize


prepare() ​

ts
prepare(coreDependencies): void;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:131

An optional function that is called before startup that will provide core dependencies to the transport. This can be used to fetch loggers, registries etc that are used in initialization steps

Parameters ​

ParameterType
coreDependenciesCoreDependencies

Returns ​

void

Implementation of ​

Transport.prepare


publish() ​

ts
publish<TEvent>(event, messageAttributes?): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:170

Publishes an event to the underlying transport. This is generally done to a topic or some other mechanism that consumers can subscribe themselves to

Type Parameters ​

Type Parameter
TEvent extends Event

Parameters ​

ParameterTypeDescription
eventTEventA domain event to be published
messageAttributes?MessageAttributes<MessageAttributeMap, MessageAttributeMap>Options that control the behaviour around how the message is sent and additional information that travels with it.

Returns ​

Promise<void>

Implementation of ​

Transport.publish


readNextMessage() ​

ts
readNextMessage(): Promise<
  | TransportMessage<Message>
| undefined>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:226

Waits for the next consumed message. A message that can't be parsed is sent to the dead letter queue and acked, and undefined is returned.

Returns ​

Promise< | TransportMessage<Message> | undefined>

Implementation of ​

Transport.readNextMessage


returnMessage() ​

ts
returnMessage(message): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:357

Returns a message to the service queue after the delay from the retry strategy, or sends it to the dead letter queue once it has been attempted maxRetries times.

The message is copied into a retry queue with a per-message TTL, and acked. When the TTL expires, the retry queue dead-letters it back to the service queue.

Parameters ​

ParameterType
messageTransportMessage<Message>

Returns ​

Promise<void>

Implementation of ​

Transport.returnMessage


send() ​

ts
send<TCommand>(command, messageAttributes?): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:177

Sends a command to the underlying transport. This is generally done to a topic or some other mechanism that consumers can subscribe themselves to

Type Parameters ​

Type Parameter
TCommand extends Command

Parameters ​

ParameterTypeDescription
commandTCommandA domain command to be sent
messageAttributes?MessageAttributes<MessageAttributeMap, MessageAttributeMap>Options that control the behaviour around how the message is sent and additional information that travels with it.

Returns ​

Promise<void>

Implementation of ​

Transport.send


start() ​

ts
start(): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:203

An optional method called on the transport when it should start consuming messages.

Returns ​

Promise<void>

Implementation of ​

Transport.start


stop() ​

ts
stop(): Promise<void>;

Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:216

An optional method called on the transport when it should no longer consume messages.

Returns ​

Promise<void>

Implementation of ​

Transport.stop

Released under the MIT License.