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

Public Member Functions

 __construct (Config\Data $queueConfigData)
 
 getExchangeByTopic ($topicName)
 
 getQueuesByTopic ($topic)
 
 getConnectionByTopic ($topic)
 
 getConnectionByConsumer ($consumer)
 
 getMessageSchemaType ($topic)
 
 getConsumerNames ()
 
 getConsumer ($name)
 
 getBinds ()
 
 getPublishers ()
 
 getConsumers ()
 
 getTopic ($name)
 
 getPublisher ($name)
 
 getResponseQueueName ($topicName)
 

Protected Member Functions

 getPublisherConfigByTopic ($topicName)
 

Protected Attributes

 $queueConfigData
 

Additional Inherited Members

- Data Fields inherited from ConfigInterface
const PUBLISHERS = 'publishers'
 
const PUBLISHER_NAME = 'name'
 
const PUBLISHER_CONNECTION = 'connection'
 
const PUBLISHER_EXCHANGE = 'exchange'
 
const TOPICS = 'topics'
 
const TOPIC_NAME = 'name'
 
const TOPIC_PUBLISHER = 'publisher'
 
const TOPIC_SCHEMA = 'schema'
 
const TOPIC_RESPONSE_SCHEMA = 'response_schema'
 
const TOPIC_SCHEMA_TYPE = 'schema_type'
 
const TOPIC_SCHEMA_VALUE = 'schema_value'
 
const TOPIC_SCHEMA_TYPE_OBJECT = 'object'
 
const TOPIC_SCHEMA_TYPE_METHOD = 'method_arguments'
 
const SCHEMA_METHOD_PARAM_NAME = 'param_name'
 
const SCHEMA_METHOD_PARAM_POSITION = 'param_position'
 
const SCHEMA_METHOD_PARAM_TYPE = 'param_type'
 
const SCHEMA_METHOD_PARAM_IS_REQUIRED = 'is_required'
 
const CONSUMERS = 'consumers'
 
const CONSUMER_NAME = 'name'
 
const CONSUMER_QUEUE = 'queue'
 
const CONSUMER_CONNECTION = 'connection'
 
const CONSUMER_INSTANCE_TYPE = 'instance_type'
 
const CONSUMER_CLASS = 'type'
 
const CONSUMER_METHOD = 'method'
 
const CONSUMER_MAX_MESSAGES = 'max_messages'
 
const CONSUMER_HANDLERS = 'handlers'
 
const CONSUMER_HANDLER_TYPE = 'type'
 
const CONSUMER_HANDLER_METHOD = 'method'
 
const CONSUMER_TYPE = 'consumer_type'
 
const CONSUMER_TYPE_SYNC = 'sync'
 
const CONSUMER_TYPE_ASYNC = 'async'
 
const RESPONSE_QUEUE_PREFIX = 'responseQueue.'
 
const BINDS = 'binds'
 
const BIND_QUEUE = 'queue'
 
const BIND_EXCHANGE = 'exchange'
 
const BIND_TOPIC = 'topic'
 
const BROKER_TOPIC = 'topic'
 
const BROKER_TYPE = 'type'
 
const BROKER_EXCHANGE = 'exchange'
 
const BROKER_CONSUMERS = 'consumers'
 
const BROKER_CONSUMER_NAME = 'name'
 
const BROKER_CONSUMER_QUEUE = 'queue'
 
const BROKER_CONSUMER_INSTANCE_TYPE = 'instance_type'
 
const BROKER_CONSUMER_MAX_MESSAGES = 'max_messages'
 
const BROKERS = 'brokers'
 
const EXCHANGE_TOPIC_TO_QUEUES_MAP = 'exchange_topic_to_queues_map'
 

Detailed Description

Queue configuration.

Deprecated:
100.2.0

Definition at line 17 of file Config.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Config\Data  $queueConfigData)
Parameters
Config\Data$queueConfigData

Definition at line 27 of file Config.php.

28  {
29  $this->queueConfigData = $queueConfigData;
30  }

Member Function Documentation

◆ getBinds()

getBinds ( )

{Get queue binds

Returns
array
See also
\Magento\Framework\MessageQueue\Topology\ConfigInterface::getExchanges
}

Implements ConfigInterface.

Definition at line 132 of file Config.php.

133  {
134  return $this->queueConfigData->get(ConfigInterface::BINDS, []);
135  }

◆ getConnectionByConsumer()

getConnectionByConsumer (   $consumer)

{

Parameters
string$consumer
Returns
string
Exceptions
LocalizedException
See also
\Magento\Framework\MessageQueue\Consumer\ConfigInterface::getConsumer
}

Implements ConfigInterface.

Definition at line 87 of file Config.php.

88  {
89  $connection = $this->queueConfigData->get(
91  );
92  if (!$connection) {
93  throw new LocalizedException(
94  new Phrase('Consumer "%consumer" has not connection.', ['consumer' => $consumer])
95  );
96  }
97  return $connection;
98  }
$connection
Definition: bulk.php:13

◆ getConnectionByTopic()

getConnectionByTopic (   $topic)

{

Parameters
string$topic
Returns
string
Exceptions
LocalizedException
See also
\Magento\Framework\MessageQueue\Publisher\ConfigInterface::getPublisher
}

Implements ConfigInterface.

Definition at line 72 of file Config.php.

73  {
74  try {
75  $publisherConfig = $this->getPublisherConfigByTopic($topic);
76  } catch (\Magento\Framework\Exception\LocalizedException $e) {
77  return null;
78  }
79  return isset($publisherConfig[ConfigInterface::PUBLISHER_CONNECTION])
80  ? $publisherConfig[ConfigInterface::PUBLISHER_CONNECTION]
81  : null;
82  }

◆ getConsumer()

getConsumer (   $name)

{Get consumer configuration

Parameters
string$name
Returns
array|null
See also
\Magento\Framework\MessageQueue\Consumer\ConfigInterface::getConsumer
}

Implements ConfigInterface.

Definition at line 123 of file Config.php.

124  {
125 
126  return $this->queueConfigData->get(ConfigInterface::CONSUMERS . '/' . $name);
127  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getConsumerNames()

getConsumerNames ( )

{Get all consumer names

Returns
string[]
See also
\Magento\Framework\MessageQueue\Consumer\ConfigInterface::getConsumers
}

Implements ConfigInterface.

Definition at line 114 of file Config.php.

115  {
116  $queueConfig = $this->queueConfigData->get(ConfigInterface::CONSUMERS, []);
117  return array_keys($queueConfig);
118  }

◆ getConsumers()

getConsumers ( )

{Get consumers

Returns
array
See also
\Magento\Framework\MessageQueue\Consumer\ConfigInterface::getConsumers
}

Implements ConfigInterface.

Definition at line 148 of file Config.php.

149  {
150  return $this->queueConfigData->get(ConfigInterface::CONSUMERS, []);
151  }

◆ getExchangeByTopic()

getExchangeByTopic (   $topicName)

{Identify configured exchange for the provided topic.

Parameters
string$topicName
Returns
string
Exceptions
LocalizedException
See also
\Magento\Framework\MessageQueue\Publisher\ConfigInterface::getPublisher
}

Implements ConfigInterface.

Definition at line 35 of file Config.php.

36  {
37  $publisherConfig = $this->getPublisherConfigByTopic($topicName);
38  return isset($publisherConfig[ConfigInterface::PUBLISHER_EXCHANGE])
39  ? $publisherConfig[ConfigInterface::PUBLISHER_EXCHANGE]
40  : null;
41  }

◆ getMessageSchemaType()

getMessageSchemaType (   $topic)

{Identify which option is used to define message schema: data interface or service method params

Parameters
string$topic
Returns
string
See also
\Magento\Framework\Communication\ConfigInterface::getTopic
}

Implements ConfigInterface.

Definition at line 103 of file Config.php.

◆ getPublisher()

getPublisher (   $name)

{Get published config

Parameters
string$name
Returns
array
See also
\Magento\Framework\MessageQueue\Publisher\ConfigInterface::getPublisher
}

Implements ConfigInterface.

Definition at line 164 of file Config.php.

165  {
166  return $this->queueConfigData->get(ConfigInterface::PUBLISHERS . '/' . $name);
167  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getPublisherConfigByTopic()

getPublisherConfigByTopic (   $topicName)
protected

Get publisher config by topic

Parameters
string$topicName
Returns
array|mixed|null
Exceptions
LocalizedException

Definition at line 184 of file Config.php.

185  {
186  $publisherName = $this->queueConfigData->get(
188  );
189 
190  if (!$publisherName) {
191  throw new LocalizedException(
192  new Phrase('Message queue topic "%topic" is not configured.', ['topic' => $topicName])
193  );
194  }
195 
196  $publisherConfig = $this->queueConfigData->get(ConfigInterface::PUBLISHERS . '/' . $publisherName);
197  if (!$publisherConfig) {
198  throw new LocalizedException(
199  new Phrase(
200  'Message queue publisher "%publisher" is not configured.',
201  ['publisher' => $publisherName]
202  )
203  );
204  }
205  return $publisherConfig;
206  }

◆ getPublishers()

getPublishers ( )

{Get publishers

Returns
array
See also
\Magento\Framework\MessageQueue\Publisher\ConfigInterface::getPublishers
}

Implements ConfigInterface.

Definition at line 140 of file Config.php.

141  {
142  return $this->queueConfigData->get(ConfigInterface::PUBLISHERS, []);
143  }

◆ getQueuesByTopic()

getQueuesByTopic (   $topic)

{Identify a list of all queue names corresponding to the specified topic (and implicitly exchange).

Parameters
string$topic
Returns
string[]
Exceptions
LocalizedException
See also
\Magento\Framework\MessageQueue\Topology\ConfigInterface::getQueues
}

Exchange should be taken into account here to avoid retrieving queues, related to another exchange, which is not currently associated with topic, but is configured in binds

Implements ConfigInterface.

Definition at line 46 of file Config.php.

47  {
48  $publisherConfig = $this->getPublisherConfigByTopic($topic);
49  $exchange = isset($publisherConfig[ConfigInterface::PUBLISHER_NAME])
50  ? $publisherConfig[ConfigInterface::PUBLISHER_NAME]
51  : null;
56  $bindKey = $exchange . '--' . $topic;
57  $output = $this->queueConfigData->get(ConfigInterface::EXCHANGE_TOPIC_TO_QUEUES_MAP . '/' . $bindKey);
58  if (!$output) {
59  throw new LocalizedException(
60  new Phrase(
61  'No bindings configured for the "%topic" topic at "%exchange" exchange.',
62  ['topic' => $topic, 'exchange' => $exchange]
63  )
64  );
65  }
66  return $output;
67  }

◆ getResponseQueueName()

getResponseQueueName (   $topicName)

{Get queue name for response

Parameters
string$topicName
Returns
string
See also
\Magento\Framework\MessageQueue\Rpc\ResponseQueueNameBuilder::getQueueName
}

Implements ConfigInterface.

Definition at line 172 of file Config.php.

173  {
174  return ConfigInterface::RESPONSE_QUEUE_PREFIX . str_replace('-', '_', $topicName);
175  }

◆ getTopic()

getTopic (   $name)

{Get topic config

Parameters
string$name
Returns
array
See also
\Magento\Framework\Communication\ConfigInterface::getTopic
\Magento\Framework\MessageQueue\Publisher\ConfigInterface::getPublisher
}

Implements ConfigInterface.

Definition at line 156 of file Config.php.

157  {
158  return $this->queueConfigData->get(ConfigInterface::TOPICS . '/' . $name);
159  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

Field Documentation

◆ $queueConfigData

$queueConfigData
protected

Definition at line 22 of file Config.php.


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