1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\MessageQueue\Topology;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Phrase;
use Magento\Framework\MessageQueue\Topology\Config\ExchangeConfigItem\Iterator as ExchangeIterator;
use Magento\Framework\MessageQueue\Topology\Config\QueueConfigItem\Iterator as QueueIterator;
/**
* Topology config provides access to data declared in etc/queue_topology.xml
*/
class Config implements ConfigInterface
{
/**
* Exchange config data iterator.
*
* @var ExchangeIterator
*/
private $exchangeIterator;
/**
* Exchange config data iterator.
*
* @var ExchangeIterator
*/
private $queueIterator;
/**
* Initialize dependencies.
*
* @param ExchangeIterator $exchangeIterator
* @param QueueIterator $queueIterator
*/
public function __construct(ExchangeIterator $exchangeIterator, QueueIterator $queueIterator)
{
$this->exchangeIterator = $exchangeIterator;
$this->queueIterator = $queueIterator;
}
/**
* {@inheritdoc}
*/
public function getExchange($name, $connection)
{
$topology = $this->exchangeIterator[$name . '--' . $connection];
if (!$topology) {
throw new LocalizedException(
new Phrase(
'The "%exchange" exchange is not declared for the "%connection" connection. Verify and try again.',
[
'exchange' => $name,
'connection' => $connection
]
)
);
}
return $topology;
}
/**
* {@inheritdoc}
*/
public function getExchanges()
{
return $this->exchangeIterator;
}
/**
* {@inheritdoc}
*/
public function getQueues()
{
return $this->queueIterator;
}
}