alchemy / rabbitmq-management-client
RabbitMQ Management Plugin API Client
Installs: 42 529
Dependents: 1
Suggesters: 0
Security: 0
Stars: 40
Watchers: 10
Forks: 24
Open Issues: 8
Requires
- doctrine/common: >=2.0
- guzzlehttp/guzzle: ~3.0
Requires (Dev)
- phpunit/phpunit: ~3.7
- react/curry: ~1.0
- react/promise: ~1.0
- react/react: ~0.2.0
- sami/sami: ~1.0
- videlalvaro/php-amqplib: dev-master@dev
Suggests
- react/react: Version 0.2 to use the async client
This package is auto-updated.
Last update: 2024-11-15 02:34:16 UTC
README
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.
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.
Synchronous Queries
Ensure a queue has a flag :
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 :
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.
Documentation
Read the documentation at Read The Docs !
License
This library is released under the MIT license (use it baby !)