# SQS

> Send messages to SQS queues and check the messages your services send to them.

Source: https://axx.nimbusxr.us/references/packs/aws-sqs/

Send messages to SQS queues and check the messages your services send to them.

The steps use the scenario's AWS account (`the {word} aws account with the following properties:`, from aws-core).

**Checking a queue receives from it**: Axx takes each message off the queue, as any consumer would. Check the queues your services **write** to (an outbound queue another system reads); a queue your service consumes is checked by what the service does with the messages. Axx starts receiving from the queues a run checks once the services are up, and a check only looks at the messages received since its scenario started. Match on data unique to the scenario: scenarios run in parallel and share the queue.

Add it to a project with `axx pack add aws-sqs`; it builds on [`aws-core`](https://axx.nimbusxr.us/references/packs/aws-core/), which comes with it.

## Steps

### `aws-sqs.send`

```gherkin
When a message is sent to the {word} sqs queue:
  """
  ...
  """
```

Send a message to the sqs queue; the doc string is its body.

| Parameter | Takes | For example |
|---|---|---|
| `{word}` | one word, with no spaces | `parcels`, `PX-4101` |

**Example:**

```gherkin
When a message is sent to the refund-results sqs queue:
  """
  {"claim": "CLM-4106", "status": "PAID", "paidAt": "2026-09-24T10:00:00Z"}
  """
```

_Since 0.1.0._

### `aws-sqs.send.file`

```gherkin
When the {filepath} message is sent to the {word} sqs queue[[ with the following attributes:]]
```

Send a message whose body is the file to the sqs queue, with the attributes of the table when the step has one.

| Parameter | Takes | For example |
|---|---|---|
| `{filepath}` | a file of the project: a path relative to the feature file's directory, the `resources` directories or axx.yaml's directory (looked for in that order), or an absolute path, quoted when it has a space | `seeds/parcels.yaml`, `kafka/scan-delivered.json` |
| `{word}` | one word, with no spaces | `parcels`, `PX-4101` |

Each row is an attribute sent with the message, as text: its name and its value.

**Variants**, the parts in `[[...]]` said or left out:

- `the {filepath} message is sent to the {word} sqs queue`
- `the {filepath} message is sent to the {word} sqs queue with the following attributes:`

**Example:**

```gherkin
When the messages/refund-failed-clm-4109.json message is sent to the refund-results sqs queue
When the messages/refund-failed-clm-4109.json message is sent to the refund-results sqs queue with the following attributes:
  | failureReason | ACCOUNT_CLOSED |
```

_Since 0.1.0._

### `aws-sqs.received`

```gherkin
Then [[within {duration} ]]the {word} sqs queue has a message where:
  | path | value |
```

The table may start with the row naming its columns, as above, or go straight to its rows.

Check that the sqs queue has a message with those values, received since the scenario started.

- The check waits for it: 10 seconds, or `within {duration}`.
- Axx takes the queue's messages off it: check queues your services write to.

| Parameter | Takes | For example |
|---|---|---|
| `{duration}` | a duration in seconds (`s`) or minutes (`m`) | `5s`, `2m` |
| `{word}` | one word, with no spaces | `parcels`, `PX-4101` |

Each row is a path into the message's JSON body (a field name, a dotted path or a JSONPath) and the value it has, compared as text: `null` for null and `undefined` for absent. A row `attribute <name>` is instead on the attribute of that name sent with the message: `undefined` when there is none.

**Variants**, the parts in `[[...]]` said or left out:

- `the {word} sqs queue has a message where:`
- `within {duration} the {word} sqs queue has a message where:`

**Example:**

```gherkin
Then within 30s the refund-requests sqs queue has a message where:
  | claim            | CLM-4101 |
  | amount           | 89.5     |
  | attribute reason | DAMAGED  |
```

_Since 0.1.0._
