Skip to content

Commit d2e5518

Browse files
committed
[Messenger] fix queue_name option amazon sqs connection
1 parent 9a6e727 commit d2e5518

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,24 @@ public function testFromDsnWithOptions()
106106
);
107107
}
108108

109+
public function testFromDsnWithQueueNameOptions()
110+
{
111+
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
112+
$this->assertEquals(
113+
new Connection(['queue_name' => 'queue'], new SqsClient(['region' => 'eu-west-1', 'accessKeyId' => null, 'accessKeySecret' => null], null, $httpClient)),
114+
Connection::fromDsn('sqs://default', ['queue_name' => 'queue'], $httpClient)
115+
);
116+
}
117+
118+
public function testFromDsnWithOverridingQueueNameByOptions()
119+
{
120+
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
121+
$this->assertEquals(
122+
new Connection(['queue_name' => 'overrided_queue'], new SqsClient(['region' => 'eu-west-1', 'accessKeyId' => null, 'accessKeySecret' => null], null, $httpClient)),
123+
Connection::fromDsn('sqs://default/queue', ['queue_name' => 'overrided_queue'], $httpClient)
124+
);
125+
}
126+
109127
public function testFromDsnWithQueryOptions()
110128
{
111129
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();

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

Lines changed: 2 additions & 1 deletion
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'] ?? ($query['poll_timeout'] ?? self::DEFAULT_OPTIONS['poll_timeout']),
102102
'visibility_timeout' => $options['visibility_timeout'] ?? ($query['visibility_timeout'] ?? self::DEFAULT_OPTIONS['visibility_timeout']),
103103
'auto_setup' => $options['auto_setup'] ?? (bool) ($query['auto_setup'] ?? self::DEFAULT_OPTIONS['auto_setup']),
104+
'queue_name' => $options['queue_name'] ?? null,
104105
];
105106

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

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

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