Let’s checkout how to connect Symfony with Amazon SQS and SNS Services by using a Symfony component. In our case we will create a TestMessage object, that gets send and consumed by a handler. Create a Symfony CLI skeleton: Install Symfony Messenger component: To enable the support of AWS SQS install these two packages: Sign in to your AWS management console and filter for SQS: Create a new Queue with the standard setup: Click the button that says “Quick-Create Queue” and you should see something like this: Below in the details Tab you will find the corresponding URL: Now we need a user with credentials that we can use in our Symfony application to send and receive messages from the queue.
You can always debug the variables that are visible to your Symfony project with this command: Last configuration steps are to change config/packages/enqueue.yaml: And the config/packages/messenger.yaml: Message(I hold the message data): Handler (I consume messages from the queue and dump the payload): Let’s see if everything fits together: As you can see we configured everything properly and it works!
First of all we need to setup a SNS Notification in our AWS management console: Click on create topic, pass a name and you get the necessary ARN that you put into your .env.local file as AWS_TOPIC_ARN=xxxxx.