Coder Social home page Coder Social logo

scroller123 / rabbitmq-management-api-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alchemy-fr/rabbitmq-management-api-client

0.0 2.0 1.0 276 KB

A OO PHP client for the RabbitMQ Management Plugin API

Home Page: https://rabbitmq-management-api-client.readthedocs.org/

License: Other

PHP 100.00%

rabbitmq-management-api-client's Introduction

RabbitMQ Manager API Client

Build Status

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 !)

rabbitmq-management-api-client's People

Contributors

romainneutron avatar robsen77 avatar cordoval avatar nlegoff avatar bburnichon avatar aztech-dev avatar

Watchers

James Cloos avatar Dmitry Vyatkin avatar

Forkers

qwep-ru

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.