Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Amqp.php
Go to the documentation of this file.
1 <?php
7 declare(strict_types=1);
8 
10 
14 class Amqp
15 {
19  private $curl;
20 
26  private $host = 'http://localhost:15672/api/';
27 
31  public function __construct()
32  {
33  $this->curl = new Curl();
34  $this->curl->setCredentials('guest', 'guest');
35  $this->curl->addHeader('content-type', 'application/json');
36  }
37 
43  public function getExchanges()
44  {
45  $this->curl->get($this->host . 'exchanges');
46  $data = $this->curl->getBody();
47  $data = json_decode($data, true);
48  $output = [];
49  foreach ($data as $value) {
50  $output[$value['name']] = $value;
51  }
52  return $output;
53  }
54 
60  public function getExchangeBindings($name)
61  {
62  $this->curl->get($this->host . 'exchanges/%2f/' . $name . '/bindings/source');
63  $data = $this->curl->getBody();
64  return json_decode($data, true);
65  }
66 
72  public function getConnections()
73  {
74  $this->curl->get($this->host . 'connections');
75  $data = $this->curl->getBody();
76  $data = json_decode($data, true);
77  $output = [];
78  foreach ($data as $value) {
79  $output[$value['name']] = $value;
80  }
81  return $output;
82  }
83 
89  public function clearQueue(string $name, int $numMessages = 50)
90  {
91  $body = [
92  "count" => $numMessages,
93  "ackmode" => "ack_requeue_false",
94  "encoding" => "auto",
95  "truncate" => 50000
96  ];
97  $this->curl->post($this->host . 'queue/%2f/' . $name . '/get', json_encode($body));
98  return $this->curl->getBody();
99  }
100 
107  public function deleteConnection($name)
108  {
109  $this->curl->delete($this->host . 'conections/' . urlencode($name));
110  $data = $this->curl->getBody();
111  return $data;
112  }
113 }
$value
Definition: gender.phtml:16
clearQueue(string $name, int $numMessages=50)
Definition: Amqp.php:89
if(!isset($_GET['name'])) $name
Definition: log.php:14