---
url: https://node-ts.github.io/bus/api/bus-sqs/classes/SqsTransport.md
---
[API reference](../../index.md) / [@node-ts/bus-sqs](../index.md) / SqsTransport

# Class: SqsTransport

Defined in: [packages/bus-sqs/src/sqs-transport.ts:86](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L86)

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

## Implements

* [`Transport`](../../bus-core/interfaces/Transport.md)<[`SqsMessage`](../interfaces/SqsMessage.md)>

## Constructors

### Constructor

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

Defined in: [packages/bus-sqs/src/sqs-transport.ts:113](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L113)

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

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `sqsConfiguration` | [`SqsTransportConfiguration`](../interfaces/SqsTransportConfiguration.md) | Settings to use when resolving queues and topics |
| `sqs?` | `SQSClient` | A preconfigured SQS service to use instead of the default |
| `sns?` | `SNSClient` | A preconfigured SNS service to use instead of the default |

#### Returns

`SqsTransport`

## Properties

| Property | Type | Defined in |
| ------ | ------ | ------ |
| <a id="property-deadletterqueueurl"></a> `deadLetterQueueUrl` | `string` | [packages/bus-sqs/src/sqs-transport.ts:98](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L98) |
| <a id="property-queueurl"></a> `queueUrl` | `string` | [packages/bus-sqs/src/sqs-transport.ts:95](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L95) |

## Methods

### deleteMessage()

```ts
deleteMessage(message): Promise<void>;
```

Defined in: [packages/bus-sqs/src/sqs-transport.ts:247](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L247)

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`](../../bus-core/interfaces/TransportMessage.md)<[`SqsMessage`](../interfaces/SqsMessage.md)> | The message to be removed from the transport |

#### Returns

`Promise`<`void`>

#### Implementation of

[`Transport`](../../bus-core/interfaces/Transport.md).[`deleteMessage`](../../bus-core/interfaces/Transport.md#deletemessage)

***

### fail()

```ts
fail(transportMessage): Promise<void>;
```

Defined in: [packages/bus-sqs/src/sqs-transport.ts:144](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L144)

Forwards

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `transportMessage` | [`TransportMessage`](../../bus-core/interfaces/TransportMessage.md)<[`SqsMessage`](../interfaces/SqsMessage.md)> | 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`](../../bus-core/interfaces/Transport.md).[`fail`](../../bus-core/interfaces/Transport.md#fail)

***

### initialize()

```ts
initialize(handlerRegistry): Promise<void>;
```

Defined in: [packages/bus-sqs/src/sqs-transport.ts:255](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L255)

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

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `handlerRegistry` | [`TransportInitializationOptions`](../../bus-core/interfaces/TransportInitializationOptions.md) | The list of messages being handled by the bus that the transport needs to subscribe to. |

#### Returns

`Promise`<`void`>

#### Implementation of

[`Transport`](../../bus-core/interfaces/Transport.md).[`initialize`](../../bus-core/interfaces/Transport.md#initialize)

***

### prepare()

```ts
prepare(coreDependencies): void;
```

Defined in: [packages/bus-sqs/src/sqs-transport.ts:123](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L123)

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`](../../bus-core/interfaces/CoreDependencies.md) |

#### Returns

`void`

#### Implementation of

[`Transport`](../../bus-core/interfaces/Transport.md).[`prepare`](../../bus-core/interfaces/Transport.md#prepare)

***

### publish()

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

Defined in: [packages/bus-sqs/src/sqs-transport.ts:130](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L130)

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`](../../bus-messages/classes/Event.md) |

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `event` | `EventType` | A domain event to be published |
| `messageAttributes?` | [`MessageAttributes`](../../bus-messages/interfaces/MessageAttributes.md)<[`MessageAttributeMap`](../../bus-messages/interfaces/MessageAttributeMap.md), [`MessageAttributeMap`](../../bus-messages/interfaces/MessageAttributeMap.md)> | Options that control the behaviour around how the message is sent and additional information that travels with it. |

#### Returns

`Promise`<`void`>

#### Implementation of

[`Transport`](../../bus-core/interfaces/Transport.md).[`publish`](../../bus-core/interfaces/Transport.md#publish)

***

### readNextMessage()

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

Defined in: [packages/bus-sqs/src/sqs-transport.ts:171](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L171)

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

#### Returns

`Promise`<
| [`TransportMessage`](../../bus-core/interfaces/TransportMessage.md)<[`SqsMessage`](../interfaces/SqsMessage.md)>
| `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`](../../bus-core/interfaces/Transport.md).[`readNextMessage`](../../bus-core/interfaces/Transport.md#readnextmessage)

***

### returnMessage()

```ts
returnMessage(message): Promise<void>;
```

Defined in: [packages/bus-sqs/src/sqs-transport.ts:251](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L251)

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

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `message` | [`TransportMessage`](../../bus-core/interfaces/TransportMessage.md)<[`SqsMessage`](../interfaces/SqsMessage.md)> | The message to be returned to the queue for reprocessing |

#### Returns

`Promise`<`void`>

#### Implementation of

[`Transport`](../../bus-core/interfaces/Transport.md).[`returnMessage`](../../bus-core/interfaces/Transport.md#returnmessage)

***

### send()

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

Defined in: [packages/bus-sqs/src/sqs-transport.ts:137](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-sqs/src/sqs-transport.ts#L137)

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`](../../bus-messages/classes/Command.md) |

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `command` | `CommandType` | A domain command to be sent |
| `messageAttributes?` | [`MessageAttributes`](../../bus-messages/interfaces/MessageAttributes.md)<[`MessageAttributeMap`](../../bus-messages/interfaces/MessageAttributeMap.md), [`MessageAttributeMap`](../../bus-messages/interfaces/MessageAttributeMap.md)> | Options that control the behaviour around how the message is sent and additional information that travels with it. |

#### Returns

`Promise`<`void`>

#### Implementation of

[`Transport`](../../bus-core/interfaces/Transport.md).[`send`](../../bus-core/interfaces/Transport.md#send)
