forked from php-enqueue/enqueue-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStompManagementClient.php
More file actions
44 lines (35 loc) · 1.15 KB
/
StompManagementClient.php
File metadata and controls
44 lines (35 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Enqueue\Client\Driver;
use RabbitMq\ManagementApi\Client;
class StompManagementClient
{
/**
* @var Client
*/
private $client;
/**
* @var string
*/
private $vhost;
public function __construct(Client $client, string $vhost = '/')
{
$this->client = $client;
$this->vhost = $vhost;
}
public static function create(string $vhost = '/', string $host = 'localhost', int $port = 15672, string $login = 'guest', string $password = 'guest'): self
{
return new self(new Client(null, 'http://'.$host.':'.$port, $login, $password), $vhost);
}
public function declareQueue(string $name, array $options)
{
return $this->client->queues()->create($this->vhost, $name, $options);
}
public function declareExchange(string $name, array $options)
{
return $this->client->exchanges()->create($this->vhost, $name, $options);
}
public function bind(string $exchange, string $queue, ?string $routingKey = null, $arguments = null)
{
return $this->client->bindings()->create($this->vhost, $exchange, $queue, $routingKey, $arguments);
}
}