brefphp / symfony-messenger

Bridge to use Symfony Messenger on AWS Lambda with Bref
MIT License
72 stars 22 forks source link

Get the eventSourceArn from $snsRecord->getTopicArn instead of getEve… #87

Closed SinaFetrat closed 4 months ago

SinaFetrat commented 4 months ago

Hi,

While trying to consume SNS events, I encountered the error No transport found for eventSource in \Bref\Symfony\Messenger\Service\MessengerTransportConfiguration. Upon investigation, I discovered that the $eventSourceArn passed to the provideTransportFromEventSource method includes a MessageId, resulting in an ARN like sns://arn:aws:sns:eu-central-1:account-id:sns-topic-name:9d572d5f-a88c-49df-9f61-81270fdb55fc.

Since each event has a different MessageId, this always triggers the No transport found for eventSource error.

This PR addresses the issue by using $snsRecord->getTopicArn() instead of $snsRecord->getEventSubscriptionArn().

@mnapoli. I would greatly appreciate it if you could review this PR, as this issue is a blocker for consuming SNS events in our project.

mnapoli commented 4 months ago

Are you saying using SNS does not work at all? I'm surprised no-one else reported that before. It would be great to have confirmation from someone that this helps.

Have you tried this fix in production? Is it working?

SinaFetrat commented 4 months ago

Yes, it is true I guess :slightly_smiling_face: I tested the fix using my branch and it works as expected in our staging environment

I think the reason no one else has experienced this issue is that the file containing the bug was introduced in this PR: https://github.com/brefphp/symfony-messenger/pull/84, and probably not many users have used this functionality since then, and all previous usages have the $transportName passed to the \Bref\Symfony\Messenger\Service\Sns\SnsConsumer or \Bref\Symfony\Messenger\Service\Sqs\SqsConsumer.

P.S: it worked perfectly for SQS events though :slightly_smiling_face:

mnapoli commented 4 months ago

Oh good point, thanks! Let's merge then.