Skip to content

Commit a44829e

Browse files
minor symfony#53524 [Messenger] [AmazonSqs] Allow async-aws/sqs version 2 (smoench)
This PR was merged into the 5.4 branch. Discussion ---------- [Messenger] [AmazonSqs] Allow `async-aws/sqs` version 2 | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | - | License | MIT With this PR async-aws/sqs version 2 would be allowed to be installed. [With version 2 they are using the AWS JSON-1.0 protocol instead of the XML one](https://github.com/async-aws/sqs/blob/master/CHANGELOG.md#200). They declared this as a BC-Break as they switced the protocol from query to json, but no public method signatures have been changed. TODO - [x] Provide JSON stubs for tests Commits ------- 96f103a [Messenger][AmazonSqs] Allow async-aws/sqs version 2
1 parent 404b553 commit a44829e

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use AsyncAws\Sqs\Result\ReceiveMessageResult;
1818
use AsyncAws\Sqs\SqsClient;
1919
use AsyncAws\Sqs\ValueObject\Message;
20+
use Composer\InstalledVersions;
2021
use PHPUnit\Framework\TestCase;
2122
use Psr\Log\NullLogger;
2223
use Symfony\Component\HttpClient\MockHttpClient;
@@ -358,6 +359,16 @@ public function testLoggerWithDebugOption()
358359

359360
private function getMockedQueueUrlResponse(): MockResponse
360361
{
362+
if ($this->isAsyncAwsSqsVersion2Installed()) {
363+
return new MockResponse(
364+
<<<JSON
365+
{
366+
"QueueUrl": "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"
367+
}
368+
JSON
369+
);
370+
}
371+
361372
return new MockResponse(<<<XML
362373
<GetQueueUrlResponse>
363374
<GetQueueUrlResult>
@@ -373,6 +384,28 @@ private function getMockedQueueUrlResponse(): MockResponse
373384

374385
private function getMockedReceiveMessageResponse(): MockResponse
375386
{
387+
if ($this->isAsyncAwsSqsVersion2Installed()) {
388+
return new MockResponse(<<<JSON
389+
{
390+
"Messages": [
391+
{
392+
"Attributes": {
393+
"SenderId": "195004372649",
394+
"ApproximateFirstReceiveTimestamp": "1250700979248",
395+
"ApproximateReceiveCount": "5",
396+
"SentTimestamp": "1238099229000"
397+
},
398+
"Body": "This is a test message",
399+
"MD5OfBody": "fafb00f5732ab283681e124bf8747ed1",
400+
"MessageId": "5fea7756-0ea4-451a-a703-a558b933e274",
401+
"ReceiptHandle": "MbZj6wDWli+JvwwJaBV+3dcjk2YW2vA3+STFFljTM8tJJg6HRG6PYSasuWXPJB+CwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQ+QEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0="
402+
}
403+
]
404+
}
405+
JSON
406+
);
407+
}
408+
376409
return new MockResponse(<<<XML
377410
<ReceiveMessageResponse>
378411
<ReceiveMessageResult>
@@ -410,4 +443,11 @@ private function getMockedReceiveMessageResponse(): MockResponse
410443
XML
411444
);
412445
}
446+
447+
private function isAsyncAwsSqsVersion2Installed(): bool
448+
{
449+
$version = InstalledVersions::getVersion('async-aws/sqs');
450+
451+
return 'dev-master' === $version || version_compare($version, '2.0.0') >= 0;
452+
}
413453
}

src/Symfony/Component/Messenger/Bridge/AmazonSqs/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.1",
2020
"async-aws/core": "^1.5",
21-
"async-aws/sqs": "^1.0",
21+
"async-aws/sqs": "^1.0|^2.0",
2222
"symfony/messenger": "^5.4|^6.0",
2323
"symfony/service-contracts": "^2.5|^3",
2424
"psr/log": "^1|^2|^3"

0 commit comments

Comments
 (0)