Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Amqp Class Reference

Public Member Functions

 __construct ()
 
 getExchanges ()
 
 getExchangeBindings ($name)
 
 getConnections ()
 
 clearQueue (string $name, int $numMessages=50)
 
 deleteConnection ($name)
 

Detailed Description

Helper class to access RabbitMQ server configuration

Definition at line 14 of file Amqp.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Initialize dependencies.

Definition at line 31 of file Amqp.php.

32  {
33  $this->curl = new Curl();
34  $this->curl->setCredentials('guest', 'guest');
35  $this->curl->addHeader('content-type', 'application/json');
36  }

Member Function Documentation

◆ clearQueue()

clearQueue ( string  $name,
int  $numMessages = 50 
)
Parameters
string$name
int$numMessages
Returns
string

Definition at line 89 of file Amqp.php.

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  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ deleteConnection()

deleteConnection (   $name)

Delete connection

Parameters
$name
Returns
string $data

Definition at line 107 of file Amqp.php.

108  {
109  $this->curl->delete($this->host . 'conections/' . urlencode($name));
110  $data = $this->curl->getBody();
111  return $data;
112  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getConnections()

getConnections ( )

Get All available connections

Returns
array

Definition at line 72 of file Amqp.php.

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  }
$value
Definition: gender.phtml:16

◆ getExchangeBindings()

getExchangeBindings (   $name)

Get declared exchange bindings.

Returns
array

Definition at line 60 of file Amqp.php.

61  {
62  $this->curl->get($this->host . 'exchanges/%2f/' . $name . '/bindings/source');
63  $data = $this->curl->getBody();
64  return json_decode($data, true);
65  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getExchanges()

getExchanges ( )

Get declared exchanges.

Returns
array

Definition at line 43 of file Amqp.php.

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  }
$value
Definition: gender.phtml:16

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