Skip to content

API reference / @node-ts/bus-sqs / SqsTransport

Class: SqsTransport ​

Defined in: packages/bus-sqs/src/sqs-transport.ts:86

A transport adapter interface that enables the service bus to use a messaging technology.

Implements ​

Constructors ​

Constructor ​

ts
new SqsTransport(
   sqsConfiguration, 
   sqs?, 
   sns?
): SqsTransport;

Defined in: packages/bus-sqs/src/sqs-transport.ts:113

An AWS SQS Transport adapter for @node-ts/bus

Parameters ​

ParameterTypeDescription
sqsConfigurationSqsTransportConfigurationSettings to use when resolving queues and topics
sqs?SQSClientA preconfigured SQS service to use instead of the default
sns?SNSClientA preconfigured SNS service to use instead of the default

Returns ​

SqsTransport

Properties ​

PropertyTypeDefined in
deadLetterQueueUrlstringpackages/bus-sqs/src/sqs-transport.ts:98
queueUrlstringpackages/bus-sqs/src/sqs-transport.ts:95

Methods ​

deleteMessage() ​

ts
deleteMessage(message): Promise<void>;

Defined in: packages/bus-sqs/src/sqs-transport.ts:247

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<SqsMessage>The message to be removed from the transport

Returns ​

Promise<void>

Implementation of ​

Transport.deleteMessage


fail() ​

ts
fail(transportMessage): Promise<void>;

Defined in: packages/bus-sqs/src/sqs-transport.ts:144

Forwards

Parameters ​

ParameterTypeDescription
transportMessageTransportMessage<SqsMessage>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(handlerRegistry): Promise<void>;

Defined in: packages/bus-sqs/src/sqs-transport.ts:255

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.

Parameters ​

ParameterTypeDescription
handlerRegistryTransportInitializationOptionsThe list of messages being handled by the bus that the transport needs to subscribe to.

Returns ​

Promise<void>

Implementation of ​

Transport.initialize


prepare() ​

ts
prepare(coreDependencies): void;

Defined in: packages/bus-sqs/src/sqs-transport.ts:123

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<EventType>(event, messageAttributes?): Promise<void>;

Defined in: packages/bus-sqs/src/sqs-transport.ts:130

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
EventType extends Event

Parameters ​

ParameterTypeDescription
eventEventTypeA 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<SqsMessage>
| undefined>;

Defined in: packages/bus-sqs/src/sqs-transport.ts:171

Fetch the next message from the underlying queue. If there are no messages, then undefined should be returned.

Returns ​

Promise< | TransportMessage<SqsMessage> | undefined>

The message construct from the underlying transport, that includes both the raw message envelope plus the contents or body that contains the @node-ts/bus-messages message.

Implementation of ​

Transport.readNextMessage


returnMessage() ​

ts
returnMessage(message): Promise<void>;

Defined in: packages/bus-sqs/src/sqs-transport.ts:251

Returns a message to the queue for retry. This will be called if an error was thrown when trying to process a message.

Parameters ​

ParameterTypeDescription
messageTransportMessage<SqsMessage>The message to be returned to the queue for reprocessing

Returns ​

Promise<void>

Implementation of ​

Transport.returnMessage


send() ​

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

Defined in: packages/bus-sqs/src/sqs-transport.ts:137

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
CommandType extends Command

Parameters ​

ParameterTypeDescription
commandCommandTypeA 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

Released under the MIT License.