Skip to content

Commit 09cc9c7

Browse files
minor #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
2 parents c32e249 + 96f103a commit 09cc9c7

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

.github/workflows/integration-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ jobs:
9595
- 8094:8094
9696
- 11210:11210
9797
sqs:
98-
image: asyncaws/testing-sqs
98+
image: localstack/localstack:3.0.2
9999
ports:
100-
- 9494:9494
100+
- 4566:4566
101101
zookeeper:
102102
image: wurstmeister/zookeeper:3.4.6
103103
kafka:
@@ -184,8 +184,8 @@ jobs:
184184
REDIS_SENTINEL_SERVICE: redis_sentinel
185185
MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages
186186
MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages
187-
MESSENGER_SQS_DSN: "sqs://localhost:9494/messages?sslmode=disable&poll_timeout=0.01"
188-
MESSENGER_SQS_FIFO_QUEUE_DSN: "sqs://localhost:9494/messages.fifo?sslmode=disable&poll_timeout=0.01"
187+
MESSENGER_SQS_DSN: "sqs://localhost:4566/messages?sslmode=disable&poll_timeout=0.01"
188+
MESSENGER_SQS_FIFO_QUEUE_DSN: "sqs://localhost:4566/messages.fifo?sslmode=disable&poll_timeout=0.01"
189189
KAFKA_BROKER: 127.0.0.1:9092
190190
POSTGRES_HOST: localhost
191191

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
"amphp/http-client": "^4.2.1",
122122
"amphp/http-tunnel": "^1.0",
123123
"async-aws/ses": "^1.0",
124-
"async-aws/sqs": "^1.0",
124+
"async-aws/sqs": "^1.0|^2.0",
125125
"async-aws/sns": "^1.0",
126126
"cache/integration-tests": "dev-master",
127127
"doctrine/annotations": "^1.13.1|^2",

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;
@@ -342,6 +343,16 @@ public function testLoggerWithDebugOption()
342343

343344
private function getMockedQueueUrlResponse(): MockResponse
344345
{
346+
if ($this->isAsyncAwsSqsVersion2Installed()) {
347+
return new MockResponse(
348+
<<<JSON
349+
{
350+
"QueueUrl": "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"
351+
}
352+
JSON
353+
);
354+
}
355+
345356
return new MockResponse(<<<XML
346357
<GetQueueUrlResponse>
347358
<GetQueueUrlResult>
@@ -357,6 +368,28 @@ private function getMockedQueueUrlResponse(): MockResponse
357368

358369
private function getMockedReceiveMessageResponse(): MockResponse
359370
{
371+
if ($this->isAsyncAwsSqsVersion2Installed()) {
372+
return new MockResponse(<<<JSON
373+
{
374+
"Messages": [
375+
{
376+
"Attributes": {
377+
"SenderId": "195004372649",
378+
"ApproximateFirstReceiveTimestamp": "1250700979248",
379+
"ApproximateReceiveCount": "5",
380+
"SentTimestamp": "1238099229000"
381+
},
382+
"Body": "This is a test message",
383+
"MD5OfBody": "fafb00f5732ab283681e124bf8747ed1",
384+
"MessageId": "5fea7756-0ea4-451a-a703-a558b933e274",
385+
"ReceiptHandle": "MbZj6wDWli+JvwwJaBV+3dcjk2YW2vA3+STFFljTM8tJJg6HRG6PYSasuWXPJB+CwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQ+QEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0="
386+
}
387+
]
388+
}
389+
JSON
390+
);
391+
}
392+
360393
return new MockResponse(<<<XML
361394
<ReceiveMessageResponse>
362395
<ReceiveMessageResult>
@@ -394,4 +427,11 @@ private function getMockedReceiveMessageResponse(): MockResponse
394427
XML
395428
);
396429
}
430+
431+
private function isAsyncAwsSqsVersion2Installed(): bool
432+
{
433+
$version = InstalledVersions::getVersion('async-aws/sqs');
434+
435+
return 'dev-master' === $version || version_compare($version, '2.0.0') >= 0;
436+
}
397437
}

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": ">=7.2.5",
2020
"async-aws/core": "^1.5",
21-
"async-aws/sqs": "^1.0",
21+
"async-aws/sqs": "^1.0|^2.0",
2222
"symfony/messenger": "^4.3|^5.0|^6.0",
2323
"symfony/service-contracts": "^1.1|^2|^3",
2424
"psr/log": "^1|^2|^3"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy