Skip to content

Commit 0091864

Browse files
committed
bug #37364 [Messenger] fixed queue_name option on amazon sqs connection (ck-developer)
This PR was merged into the 5.1 branch. Discussion ---------- [Messenger] fixed queue_name option on amazon sqs connection | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #37293 | License | MIT Commits ------- a6cb24d [Messenger] fixed queue_name option amazon sqs connection
2 parents 71b65d4 + a6cb24d commit 0091864

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,21 @@ public function testFromDsnWithQueryOptions()
124124
);
125125
}
126126

127+
public function testFromDsnWithQueueNameOption()
128+
{
129+
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
130+
131+
$this->assertEquals(
132+
new Connection(['queue_name' => 'queue'], new SqsClient(['region' => 'eu-west-1', 'accessKeyId' => null, 'accessKeySecret' => null], null, $httpClient)),
133+
Connection::fromDsn('sqs://default', ['queue_name' => 'queue'], $httpClient)
134+
);
135+
136+
$this->assertEquals(
137+
new Connection(['queue_name' => 'queue'], new SqsClient(['region' => 'eu-west-1', 'accessKeyId' => null, 'accessKeySecret' => null], null, $httpClient)),
138+
Connection::fromDsn('sqs://default/queue', ['queue_name' => 'queue_ignored'], $httpClient)
139+
);
140+
}
141+
127142
public function testKeepGettingPendingMessages()
128143
{
129144
$client = $this->createMock(SqsClient::class);

src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
101101
'poll_timeout' => $options['poll_timeout'],
102102
'visibility_timeout' => $options['visibility_timeout'],
103103
'auto_setup' => (bool) $options['auto_setup'],
104+
'queue_name' => (string) $options['queue_name'],
104105
];
105106

106107
$clientConfiguration = [
@@ -119,8 +120,8 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
119120
}
120121

121122
$parsedPath = explode('/', ltrim($parsedUrl['path'] ?? '/', '/'));
122-
if (\count($parsedPath) > 0) {
123-
$configuration['queue_name'] = end($parsedPath);
123+
if (\count($parsedPath) > 0 && !empty($queueName = end($parsedPath))) {
124+
$configuration['queue_name'] = $queueName;
124125
}
125126
$configuration['account'] = 2 === \count($parsedPath) ? $parsedPath[0] : null;
126127

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