Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TopologyInstaller.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Framework\Amqp;
7 
11 
16 {
20  private $topologyConfig;
21 
25  private $exchangeInstaller;
26 
30  private $configPool;
31 
35  private $queueInstaller;
36 
40  private $connectionTypeResolver;
41 
45  protected $logger;
46 
57  public function __construct(
58  ConfigInterface $topologyConfig,
59  ExchangeInstaller $exchangeInstaller,
60  ConfigPool $configPool,
61  QueueInstaller $queueInstaller,
62  ConnectionTypeResolver $connectionTypeResolver,
63  \Psr\Log\LoggerInterface $logger
64  ) {
65  $this->topologyConfig = $topologyConfig;
66  $this->exchangeInstaller = $exchangeInstaller;
67  $this->configPool = $configPool;
68  $this->queueInstaller = $queueInstaller;
69  $this->connectionTypeResolver = $connectionTypeResolver;
70  $this->logger = $logger;
71  }
72 
78  public function install()
79  {
80  try {
81  foreach ($this->topologyConfig->getQueues() as $queue) {
82  if ($this->connectionTypeResolver->getConnectionType($queue->getConnection()) != 'amqp') {
83  continue;
84  }
85  $amqpConfig = $this->configPool->get($queue->getConnection());
86  $this->queueInstaller->install($amqpConfig->getChannel(), $queue);
87  }
88  foreach ($this->topologyConfig->getExchanges() as $exchange) {
89  if ($this->connectionTypeResolver->getConnectionType($exchange->getConnection()) != 'amqp') {
90  continue;
91  }
92  $amqpConfig = $this->configPool->get($exchange->getConnection());
93  $this->exchangeInstaller->install($amqpConfig->getChannel(), $exchange);
94  }
95  } catch (\Exception $e) {
96  $this->logger->error("AMQP topology installation failed: {$e->getMessage()}\n{$e->getTraceAsString()}");
97  }
98  }
99 }
$queue
Definition: queue.php:21
__construct(ConfigInterface $topologyConfig, ExchangeInstaller $exchangeInstaller, ConfigPool $configPool, QueueInstaller $queueInstaller, ConnectionTypeResolver $connectionTypeResolver, \Psr\Log\LoggerInterface $logger)