PHP code example of wyrihaximus / react-observable-bunny

1. Go to this page and download the library: Download wyrihaximus/react-observable-bunny 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/ */

    

wyrihaximus / react-observable-bunny example snippets




use Bunny\Async\Client;
use React\EventLoop\Factory;
use WyriHaximus\React\ObservableBunny\Message;
use WyriHaximus\React\ObservableBunny\ObservableBunny;

$loop = Factory::create();
$bunny = new Client($loop);
$observableBunny = new ObservableBunny($loop, $bunny);
// OR to check the dispose status on another interval then once a second, like twice a second
$observableBunny = new ObservableBunny($loop, $bunny, 0.5);
$queue = $observableBunny->consume('queue:name', [0, 10]);
$loop->addTimer(120, function () use ($queue, $bunny) {
    $queue->dispose();
    $bunny->disconnect();
});
$queue->subscribe(function (Message $message) {
    // Handle message
});

$loop->run();