# SQS

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

Source: https://axx.nimbusxr.us/references/steps/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 apps 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.

## `aws-sqs.send`

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

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

**Parameters:** `{word}` (one word, no spaces)

**Example:**

```gherkin
When a message is sent to the refund-requests sqs queue:
```

_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 (resolved against `resources`) to a sqs queue, with the attributes of the table (`name | value`).

**Variants** (optional parts in `[[...]]` above):

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

**Parameters:** `{filepath}` (A file of the project, without whitespace: a path relative to the `resources` directories or to the directory of axx.yaml, or an absolute path. Editors link it to the file), `{word}` (one word, no spaces)

**Example:**

```gherkin
When the messages/shipment-delivered.json message is sent to the refund-requests sqs queue
When the messages/shipment-delivered.json message is sent to the refund-requests sqs queue with the following attributes:
```

_Since 0.1.0._

## `aws-sqs.received`

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

Wait (10s, or the given time) until the sqs queue has a message, received since the scenario started, that meets every row: `path | value` on the JSON body (a field name, a dotted path or a JSONPath, compared as text; `null` for null and `undefined` for absent), or `attribute <name> | value` on a attribute sent with it. Axx takes the queue's messages off it: check queues your services write to.

**Variants** (optional parts in `[[...]]` above):

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

**Parameters:** `{duration}` (A duration in seconds or minutes, e.g. `5s` or `2m`), `{word}` (one word, no spaces)

**Example:**

```gherkin
Then within 30s the refund-requests sqs queue has a message where:
```

_Since 0.1.0._
