This small package helps you install and configure Symfony Messenger with SNS. If installed with Flex you will have most things configured for you.
This file will be "composer copied" to your projects bin folder (ie vendor/bin/message-consumer
). This file receives
SNS messages and gives them to App\Consumer\SnsConsumer
.
This class is responsible to decode the SNS message and put it back on the message bus. It dispatches events which one can subscribe to in order to modify behavior. Ie, retry failed events.
This file will be copied by Flex to config/packages/sns-consumer.yaml
. It contains example configuration for
Messenger and Enqueue Bundle.
Here is a small snippet to make sure we configure a consumer for SNS with Bref.
Resources:
Consumer:
Type: AWS::Serverless::Function
Properties:
FunctionName: 'my-app-consumer'
Handler: vendor/bin/message-consumer
Timeout: 20 # in seconds
MemorySize: 2048
# ...
Events:
Sns:
Type: SNS
Properties:
Topic: arn:aws:sns:eu-central-1:xxxxxxx:my_sns_topic
When working in production we are using SNS but in local development we may want to use something simpler, say RabbitMQ.
# .env
# Production
AWS_SNS_DSN=enqueue://acme?topic[name]=my_sns_topic
# Development
AWS_SNS_DSN=amqp://guest:guest@127.0.0.1:5672/%2f/fake_sns
Then you can consume messages are you normally would with bin/console messenger:consume
.