Skip to content

Commit 9f6ee1f

Browse files
committed
Merge branch 'ACP2E-2066' of https://github.com/magento-l3/magento2ce into PR-L3-08112023
2 parents ba4ba91 + f2a44b6 commit 9f6ee1f

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

lib/internal/Magento/Framework/MessageQueue/Config/Reader/Env/Converter/Publisher.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
}
2828

2929
/**
30-
* {@inheritDoc}
30+
* @inheritdoc
3131
*/
3232
public function convert($source)
3333
{
@@ -40,10 +40,12 @@ public function convert($source)
4040
if (isset($configuration['connections'])) {
4141
$publisherData = [];
4242
foreach ($configuration['connections'] as $connectionName => $config) {
43-
if (isset($this->connectionToExchangeMap[$connectionName])) {
44-
$publisherName = $connectionName . '-' . $this->connectionToExchangeMap[$connectionName];
43+
$exchange = $config['exchange'] ?? $this->connectionToExchangeMap[$connectionName] ?? null;
44+
if ($exchange) {
45+
$publisherName = $connectionName . '-' . $exchange;
4546
$config['connection'] = $config['name'];
4647
$config['name'] = $publisherName;
48+
$config['exchange'] = $exchange;
4749
$publisherData[$publisherName] = $config;
4850
$connections = array_replace_recursive($connections, $publisherData);
4951
}

lib/internal/Magento/Framework/MessageQueue/Test/Unit/Config/Reader/Env/Converter/PublisherTest.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,41 @@ protected function setUp(): void
3232
public function testConvert()
3333
{
3434
$source = include __DIR__ . '/../../../../_files/env_2_2.php';
35+
$expectedConfig = [
36+
'amqp-magento-db' => [
37+
'name' => 'amqp-magento-db',
38+
'exchange' => 'magento-db',
39+
'connection' =>'db'
40+
]
41+
];
42+
$actualResult = $this->converter->convert($source['config']);
43+
$this->assertEquals($expectedConfig, $actualResult[ReaderEnv::ENV_PUBLISHERS]);
44+
}
45+
46+
public function testConvertUndefinedExchange()
47+
{
48+
$source = [
49+
'config' => [
50+
'publishers' => [
51+
'inventory.counter.updated' => [
52+
'connections' => [
53+
'amqp' => [
54+
'name' => 'db',
55+
],
56+
]
57+
]
58+
],
59+
'consumers' => [
60+
'inventoryQtyCounter' => [
61+
'connection' => 'db'
62+
]
63+
]
64+
]
65+
];
3566
$expectedConfig = [
3667
'amqp-magento' => [
3768
'name' => 'amqp-magento',
38-
'exchange' => 'magento-db',
69+
'exchange' => 'magento',
3970
'connection' =>'db'
4071
]
4172
];

0 commit comments

Comments
 (0)