PHP code example of pmill / rabbit-rabbit-cloudwatch

1. Go to this page and download the library: Download pmill/rabbit-rabbit-cloudwatch 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-cloudwatch example snippets


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

$manager = new ConsumerManager($config);

$vhostName = '/';
$queueName = 'messages';
$metricName = 'queue_:queueName';

$cloudWatchClient = new CloudWatchClient([
    'version' => 'latest',
    'region' => 'eu-west-1',
    'credentials' => [
        'key' => '',
        'secret' => '',
    ],
]);

$manager->addRule(
    new CloudWatchRule(
        $vhostName,
        $queueName,
        $cloudWatchClient,
        $metricName
    ),
    new GreaterThan(0)
);

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