2017 © Pedro Peláez
 

library rabbitmq-management-client

RabbitMQ Management Plugin API Client

image

alchemy/rabbitmq-management-client

RabbitMQ Management Plugin API Client

  • Monday, March 20, 2017
  • by bburnichon
  • Repository
  • 8 Watchers
  • 36 Stars
  • 11,922 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 20 Forks
  • 7 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

RabbitMQ Manager API Client

Build Status, (*1)

This library is intended to help management of RabbitMQ server in an application. It provides two ways to query RabbitMQ : Synchronous query with Guzzle and Asynchronous query with React., (*2)

Asynchronous Queries


use RabbitMQ\Management\AsyncAPIClient; use React\EventLoop\Factory; $loop = Factory::create(); $client = AsyncAPIClient::factory($loop, array( 'url' => '127.0.0.1', )); $loop->addPeriodicTimer(1, function () use ($client) { $client->listQueues() ->then(function($queues) { echo "\n------------\n"; foreach ($queues as $queue) { echo sprintf("Found queue %s with %d messages\n", $queue->name, $queue->messages); } }, function ($error) { echo "An error occured : $error\n"; }); }); $loop->run();

Asynchronous Client do not currently support Guarantee API., (*3)

Synchronous Queries

Ensure a queue has a flag :, (*4)

use RabbitMQ\Management\APIClient;
use RabbitMQ\Management\Entity\Queue;
use RabbitMQ\Management\Exception\EntityNotFoundException;

$client = APIClient::factory(array('url'=>'localhost'));

try {
    $queue = $client->getQueue('/', 'queue.leuleu');

    if (true !== $queue->durable) {
        $queue->durable = true;

        $client->deleteQueue('/', 'queue.leuleu');
        $client->addQueue($queue);
    }

} catch (EntityNotFoundException $e) {
    $queue = new Queue();
    $queue->vhost = '/';
    $queue->name = 'queue.leuleu';
    $queue->durable = true;

    $client->addQueue($queue);
}

You can also use the Guarantee manager :, (*5)

use RabbitMQ\Management\APIClient;
use RabbitMQ\Management\Entity\Queue;
use RabbitMQ\Management\Guarantee;

$client = APIClient::factory(array('url'=>'localhost'));
$manager = new Guarantee($client);

$queue = new Queue();
$queue->vhost = '/';
$queue->name = 'queue.leuleu';
$queue->durable = true;
$queue->auto_delete = false;

$queue = $manager->ensureQueue($queue);

API Browser

Browse the API here., (*6)

Documentation

Read the documentation at Read The Docs !, (*7)

License

This library is released under the MIT license (use it baby !), (*8)

The Versions

20/03 2017
23/11 2012

dev-Async

dev-Async

RabbitMQ Management Plugin API Client

  Sources   Download

MIT

The Requires

 

The Development Requires

api rabbitmq management