Skip to content

Commit f60068d

Browse files
committed
[Messenger] fixed queue_name option amazon sqs connection
1 parent d033677 commit f60068d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

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

127+
public function testFromDsnWithQueueNameOption()
128+
{
129+
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
130+
$this->assertEquals(
131+
new Connection(['queue_name' => 'queue'], new SqsClient(['region' => 'eu-west-1', 'accessKeyId' => null, 'accessKeySecret' => null], null, $httpClient)),
132+
Connection::fromDsn('sqs://default', ['queue_name' => 'queue'], $httpClient)
133+
);
134+
}
135+
127136
public function testKeepGettingPendingMessages()
128137
{
129138
$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