PHP code example of pmill / rabbit-rabbit-ecs

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


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

$manager = new ConsumerManager($config);

$vhostName = '/';
$queueName = 'messages';
$ecsClusterName = 'default';
$ecsServiceName = 'sample-webapp';

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

$manager->addRule(
    new EcsRule(
        $vhostName,
        $queueName,
        $ecsClient,
        $ecsClusterName,
        $ecsServiceName,
        1
    ),
    new CountBetween(0, 4999)
);

$manager->addRule(
    new EcsRule(
        $vhostName,
        $queueName,
        $ecsClient,
        $ecsClusterName,
        $ecsServiceName,
        3
    ),
    new GreaterThan(5000)
);

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