Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Exchange.php
Go to the documentation of this file.
1 <?php
7 
9 use Magento\Framework\MessageQueue\ConfigInterface as MessageQueueConfig;
11 
15 class Exchange implements ExchangeInterface
16 {
20  private $messageQueueConfig;
21 
25  private $queueManagement;
26 
33  public function __construct(MessageQueueConfig $messageQueueConfig, QueueManagement $queueManagement)
34  {
35  $this->messageQueueConfig = $messageQueueConfig;
36  $this->queueManagement = $queueManagement;
37  }
38 
42  public function enqueue($topic, array $envelopes)
43  {
44  $queueNames = $this->messageQueueConfig->getQueuesByTopic($topic);
45  $messages = array_map(
46  function ($envelope) {
47  return $envelope->getBody();
48  },
49  $envelopes
50  );
51  $this->queueManagement->addMessagesToQueues($topic, $messages, $queueNames);
52 
53  return null;
54  }
55 }
enqueue($topic, array $envelopes)
Definition: Exchange.php:42
__construct(MessageQueueConfig $messageQueueConfig, QueueManagement $queueManagement)
Definition: Exchange.php:33