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
Transport<RabbitMqMessage>
Constructors
Constructor
new RabbitMqTransport(configuration): RabbitMqTransport;Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:117
Parameters
| Parameter | Type |
|---|---|
configuration | RabbitMqTransportConfiguration |
Returns
RabbitMqTransport
Methods
connect()
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
| Parameter | Type |
|---|---|
options | TransportConnectionOptions |
Returns
Promise<void>
Implementation of
deleteMessage()
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
| Parameter | Type | Description |
|---|---|---|
message | TransportMessage<Message> | The message to be removed from the transport |
Returns
Promise<void>
Implementation of
disconnect()
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
fail()
fail(transportMessage): Promise<void>;Defined in: packages/bus-rabbitmq/src/rabbitmq-transport.ts:184
Forwards
Parameters
| Parameter | Type | Description |
|---|---|---|
transportMessage | TransportMessage<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
initialize()
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
prepare()
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
| Parameter | Type |
|---|---|
coreDependencies | CoreDependencies |
Returns
void
Implementation of
publish()
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
| Parameter | Type | Description |
|---|---|---|
event | TEvent | A 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
readNextMessage()
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
returnMessage()
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
| Parameter | Type |
|---|---|
message | TransportMessage<Message> |
Returns
Promise<void>
Implementation of
send()
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
| Parameter | Type | Description |
|---|---|---|
command | TCommand | A 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
start()
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
stop()
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>