> For the complete documentation index, see [llms.txt](https://docs.ecotone.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecotone.tech/messaging/contributing-to-ecotone/demo-integration-with-sqs/preparation.md).

# Preparation

Let's integrate real life scenario together and make integration with [Amazon SQS](https://aws.amazon.com/sqs/).\
To provide custom Message Channels, that will be backed by Amazon SQS.\
This will allow us to send Ecotone's Messages over SQS.

{% hint style="success" %}
Even, if you do not want to integrate new Module, it's still worth of going through demo, to see how messaging patterns are used and how to write tests.
{% endhint %}

## Preparation

In the demo we will be using package name `SqsDemo.` In repository you will find `_PackageTemplate` that can be used for bootraping your module.\
Start by replacing `_PackageTemplate` with `SqsDemo`.

{% hint style="info" %}
Before starting check [previous chapter](/messaging/contributing-to-ecotone/registering-new-module-package.md).
{% endhint %}

Our composer `autoload` will be like this:

```json
"autoload": {
    "psr-4": {
        "Ecotone\\SqsDemo\\": "src"
    }
},
"autoload-dev": {
    "psr-4": {
        "Test\\Ecotone\\SqsDemo\\": [
            "tests"
        ]
    }
}
```

As Ecotone encourage writing tests on real integrations instead of mocked libraries, we will add docker container, that will provide us with self-hosted `Amazon SQS`.\
We will be using [localstack](https://github.com/localstack/localstack) for hosting local SQS, let's start by adding it to `docker-compose.yaml`.

```
localstack:
  image: localstack/localstack:0.8.10
  networks:
    - default
  environment:
    HOSTNAME_EXTERNAL: 'localstack'
    SERVICES: 'sqs'
```

then by running `docker-compose up -d` it will be now available for us in testing under http\://`localstack-sqs-demo:4576` hostname.

## Adding required composer package

Ecotone provides basic integration with [enqueue libraries](https://github.com/php-enqueue) that we can build on top of.

{% hint style="info" %}
You may check on [enqueue github](https://github.com/php-enqueue), if it provides integration with service that you would like integrate Ecotone with. If so, then we will need to write less code, as part of the integration it already covered.
{% endhint %}

So the package we are interested is `enqueue/sqs`, let's add this and `ecotone/enqueue`.

```bash
composer require enqueue/sqs && composer require ecotone/enqueue
```

You may take a look on the [API of SQS](https://php-enqueue.github.io/transport/sqs/) over enqueue before we will go to the next step.

{% hint style="success" %}
Always prefer to use well known packages for low level integration with external services. This decrease amount of integration that needs to be maintained and does not reinvent the wheel.
{% endhint %}

## Register Module Package

Start by adding our `sqsDemo` package `ModulePackageList` and `ModuleClassList` in the same way as other modules are added there. This will allow us to run this package from our tests.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ecotone.tech/messaging/contributing-to-ecotone/demo-integration-with-sqs/preparation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
