Preparation
Let's integrate real life scenario together and make integration with Amazon SQS. To provide custom Message Channels, that will be backed by Amazon SQS. This will allow us to send Ecotone's Messages over SQS.
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.
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
.
Before starting check previous chapter.
Our composer autoload
will be like this:
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 for hosting local SQS, let's start by adding it to docker-compose.yaml
.
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 that we can build on top of.
You may check on enqueue github, 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.
So the package we are interested is enqueue/sqs
, let's add this and ecotone/enqueue
.
You may take a look on the API of SQS over enqueue before we will go to the next step.
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.
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.
Last updated