Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
TopologyInstaller Class Reference
Inheritance diagram for TopologyInstaller:
Topology

Public Member Functions

 __construct (ConfigInterface $topologyConfig, ExchangeInstaller $exchangeInstaller, ConfigPool $configPool, QueueInstaller $queueInstaller, ConnectionTypeResolver $connectionTypeResolver, \Psr\Log\LoggerInterface $logger)
 
 install ()
 

Protected Attributes

 $logger
 

Detailed Description

Class Topology creates topology for Amqp messaging

Definition at line 15 of file TopologyInstaller.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ConfigInterface  $topologyConfig,
ExchangeInstaller  $exchangeInstaller,
ConfigPool  $configPool,
QueueInstaller  $queueInstaller,
ConnectionTypeResolver  $connectionTypeResolver,
\Psr\Log\LoggerInterface  $logger 
)

Initialize dependencies.

Parameters
ConfigInterface$topologyConfig
ExchangeInstaller$exchangeInstaller
ConfigPool$configPool
QueueInstaller$queueInstaller
ConnectionTypeResolver$connectionTypeResolver
\Psr\Log\LoggerInterface$logger

Definition at line 57 of file TopologyInstaller.php.

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  }

Member Function Documentation

◆ install()

install ( )

Install Amqp Exchanges, Queues and bind them

Returns
void

Definition at line 78 of file TopologyInstaller.php.

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  }
$queue
Definition: queue.php:21

Field Documentation

◆ $logger

$logger
protected

Definition at line 45 of file TopologyInstaller.php.


The documentation for this class was generated from the following file: