PHP code example of pmill / rabbit-rabbit-statsd

1. Go to this page and download the library: Download pmill/rabbit-rabbit-statsd library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pmill / rabbit-rabbit-statsd example snippets


$config = new RabbitConfig([
    'baseUrl' => 'localhost:15672',
    'username' => 'guest',
    'password' => 'guest',
]);

$manager = new ConsumerManager($config);

$vhostName = '/';
$queueName = 'messages';
$metric = 'message_queue_count';

$statsDClient = new StatsDClient();
$statsDClient->configure([
    'host' => '127.0.0.1',
    'port' => 8125,
    'namespace' => 'example'
]);

$manager->addRule(
    new StatsDRule(
        $vhostName,
        $queueName,
        $statsDClient,
        $metric
    ),
    new GreaterThan(0)
);

$manager->run();
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php