Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bref/symfony-messenger #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Symfony/sqs/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Pre-requests

Before we start we need to setup the QUEUE. Bref works with both FIFO queues and normal queues. Try to create a new normal
SQS queue, name it "foobar" and click "quick create".
Before we start we need to setup the QUEUE. Bref works with both FIFO queues and standard queues. Try to create a new "standard
queue", name it "foobar" and click "quick create".

Example queue ARN: **arn:aws:sqs:us-east-1:403367587399:foobar**
Example queue URL: **https://sqs.us-east-1.amazonaws.com/403367587399/foobar**
Expand Down Expand Up @@ -36,7 +36,7 @@ The last thing we need to do is to allow write access to the queue.

1. Go to IAM in the AWS console
2. Click "Roles" in the left sidebar
3. Find the roles for this Lambda application and click on it. Probably named something like "bref-demo-sqs"
3. Find the roles for this Lambda application and click on it. Probably named something like "bref-demo-sqs-dev-...-LambdaRole"
4. Now click "Attach policy" and find "SQSFullAccess" in the list. After you added that policy you are good to go.

You can obviously be more restrictive with what policy to add.
6 changes: 3 additions & 3 deletions Symfony/sqs/bin/consumer.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php declare(strict_types=1);

use Bref\Messenger\Sqs\SqsConsumer;
use Bref\Messenger\Service\BrefWorker;
Nyholm marked this conversation as resolved.
Show resolved Hide resolved

require dirname(__DIR__) . '/config/bootstrap.php';

lambda(function ($event) {
$kernel = new \App\Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();

$sqsConsumer = $kernel->getContainer()->get(SqsConsumer::class);
$sqsConsumer->consumeLambdaEvent($event);
$worker = $kernel->getContainer()->get(BrefWorker::class);
$worker->consumeLambdaEvent($event);
});
5 changes: 4 additions & 1 deletion Symfony/sqs/composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"type": "project",
"license": "proprietary",
"repositories": [
{ "type": "vcs", "url": "https://github.com/Nyholm/bref-symfony-messenger"}
],
Nyholm marked this conversation as resolved.
Show resolved Hide resolved
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"bref/bref": "^0.5.12",
"bref/symfony-messenger-sqs": "^0.2.0",
"bref/symfony-messenger": "dev-master",
"symfony/console": "4.4.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "4.4.*",
Expand Down
76 changes: 45 additions & 31 deletions Symfony/sqs/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions Symfony/sqs/config/packages/messenger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ framework:
routing:
'App\Message\Ping': async

bref_messenger:
sqs: true # Register the SQS transport

services:

Bref\Messenger\Sqs\SqsConsumer:
autowire: true
autoconfigure: true
my_sqs_consumer:
class: Bref\Messenger\Service\Sqs\SqsConsumer
arguments:
# Inject the transport name used in config/packages/messenger.yaml
$transportName: 'async'
public: true
- '@Bref\Messenger\Service\BusDriver'
- '@messenger.routable_message_bus'
- '@Symfony\Component\Messenger\Transport\Serialization\SerializerInterface'
- 'async' # Same as transport name
tags:
- { name: bref_messenger.consumer }
3 changes: 3 additions & 0 deletions Symfony/sqs/symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"bref/bref": {
"version": "0.5.12"
},
"bref/symfony-messenger": {
"version": "dev-master"
},
"bref/symfony-messenger-sqs": {
"version": "0.2.0"
},
Expand Down