bref/symfony-messenger-sns

This package is abandoned and no longer maintained. The author suggests using the bref/symfony-messenger package instead.

Installs and confgures SNS with Symfony Messenger

0.2.0 2019-06-28 09:01 UTC

This package is auto-updated.

Last update: 2021-03-04 10:24:47 UTC


README

This small package helps you install and configure Symfony Messenger with SNS. If installed with Flex you will have most things configured for you.

Package contents

bin/message-consumer

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.

src/Consumer.php

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.

config/sns-consumer.yaml

This file will be copied by Flex to config/packages/sns-consumer.yaml. It contains example configuration for Messenger and Enqueue Bundle.

Bref template

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

Local Development

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.