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

[Messenger] Support SQS Transport with QueueUrl as DSN #37305

Closed
starred-gijs opened this issue Jun 16, 2020 · 3 comments · Fixed by #37306
Closed

[Messenger] Support SQS Transport with QueueUrl as DSN #37305

starred-gijs opened this issue Jun 16, 2020 · 3 comments · Fixed by #37306

Comments

@starred-gijs
Copy link
Contributor

Description
The Amazon SQS Transport now only supports a DSN that starts with sqs://,
but especially with CloudFormation the QueueUrl could be provided as an environment variable.

See brefphp/symfony-messenger#30 (comment)

Example

MESSENGER_TRANSPORT_DSN=https://sqs.us-east-2.amazonaws.com/123456789012/ab1-MyQueue-A2BCDEF3GHI4
@mnapoli
Copy link
Contributor

mnapoli commented Jun 17, 2020

To expand on this, this is very valuable when creating serverless applications via serverless.yml or any kind of "Infrastructure as Code" tool.

Here is an example where we can very simply put the queue URL returned by SQS into an environment variable:

provider:
    ...
    environment:
        APP_ENV: prod
        SQS_URL:
            Ref: AlertQueue

resources:
    Resources:
        AlertQueue:
            Type: AWS::SQS::Queue

Without that feature, we would have to transform the queue URL to match Symfony's prefix (sqs://), which is hard to do here.

Solving that issue would allow to merge Bref's Symfony Messenger bridge with the official SQS driver.

FYI SQS URLs are distinguishable via a prefix, this is what is done in Bref:

https://github.com/brefphp/symfony-messenger/blob/3ee64570ba6b5693052e4e8eb601ee8d2765392a/src/Service/Sqs/SqsTransportFactory.php#L29

    public function supports(string $dsn, array $options): bool
    {
        return preg_match('#^https://sqs\.[\w\-]+\.amazonaws\.com/.+#', $dsn) === 1;
    }

@gmponos
Copy link
Contributor

gmponos commented Jun 17, 2020

Can I bring another perspective here...

If I was allowed to tag a service as a Transport.. Then would I be able to initialize my SqsService with the plain URL?

AFAIK I can't tag services as transports and avoid factories.. Allowing the above, I could declare my own Connection with the simple URL and pass it to my own Transport..

Then I could use it into routing..

@mnapoli
Copy link
Contributor

mnapoli commented Jun 22, 2020

awesome thanks @starred-gijs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants