innmind/rabbitmq-management

Abstraction for the rabbitmq management

3.2.0 2023-09-23 09:25 UTC

This package is auto-updated.

Last update: 2024-11-23 11:46:14 UTC


README

Build Status codecov Type Coverage

Wrapper for the rabbitmqadmin command.

Installation

composer require innmind/rabbitmq-management

Usage

use Innmind\RabbitMQ\Management\{
    Status,
    Control,
};
use Innmind\OperatingSystem\Factory;

$os = Factory::build();
$status = Status::of(
    $os->control(),
    $os->clock(),
);
$status->users();
$status->vhosts();
$status->connections();
$status->exchanges();
$status->permissions();
$status->channels();
$status->consumers();
$status->queues();
$status->nodes();

$control = Control::of($server);
$control->users();
$control->vhosts();
$control->permissions();

Essentially this will run rabbitmqadmin list {element} on the server and extract informations.

If you need to list the information of a remote server, then you can simply do this:

use Innmind\RabbitMQ\Management\Status\Environment\Remote;
use Innmind\Url\{
    Authority\Host,
    Authority\Port,
    Path,
};

Status::of(
    $os->control(),
    $os->clock(),
    Remote::of(
        Host::of('your-host'),
        Port::of(1337),
        'username',
        'password',
        Path::of('/some-vhost'),
    ),
);

However for this to work you need to have rabbitmqadmin installed on the machine this code will run.

In case you don't have the command on the machine, you can replace $os->control() by $os->remote()->ssh(/*...*/) so it will use ssh to run the command on the machine (and you will need to remove the third argument from Status::of()).