2017 © Pedro Peláez
 

library bunny

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

image

domraider/bunny

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  • Wednesday, January 11, 2017
  • by vince.ve
  • Repository
  • 4 Watchers
  • 1 Stars
  • 6,049 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 50 Forks
  • 0 Open issues
  • 14 Versions
  • 13 % Grown

The README.md

BunnyPHP

Fork to handle automatic reconnect :, (*1)

require "vendor/autoload.php";

$loop = \React\EventLoop\Factory::create();
$mq = new \Bunny\Async\Client($loop, [
    'host' => '127.0.0.1',
    'port' => 5672,
    'user' => 'guest',
    'password' => 'guest',
]);

// Connect is refactored to be retryable
$mq->connect()
    ->retryWhen(function ($errors) {
        // Retry to connect on error
        return $errors->delay(2000)
            ->doOnNext(function () {
                echo "Disconnected, retry\n";
            });
    })
    ->flatMap(function () use ($mq) {
        // Open only 1 channel
        return $mq->channel();
    })
    ->subscribeCallback(function (\Bunny\Channel $channel) use ($mq, $loop) {
        echo "connected\n";
        // Publish every 2s
        \Rx\Observable::interval(2000)
            // <- here we drop during disconnect
            // <- You have to add a buffer
            ->flatMap(function () use ($mq, $channel) {
                $data = md5(microtime(true));
                echo "Produce {$data}\n";
                return \Rx\React\Promise::toObservable($channel->publish($data, [], 'amq.direct', 'test'))
                    ->map(function () use ($data) {
                        return $data;
                    });

            })
            ->subscribeCallback(
                function ($data) {
                    echo "  {$data} : OK\n";
                },
                function () {
                    echo "error during produce\n";
                }, null,
                new \Rx\Scheduler\EventLoopScheduler($loop)
            );
    }, function (\Exception $e) {
        echo "disconnected : {$e->getMessage()}\n";
    }, null, new \Rx\Scheduler\EventLoopScheduler($loop));


$loop->run();

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library, (*2)

The Versions

11/01 2017

dev-master

9999999-dev

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

11/01 2017

0.3.1

0.3.1.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

23/11 2016

0.3.0

0.3.0.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

13/09 2016

v0.2.4

0.2.4.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

31/05 2016

v0.2.3

0.2.3.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

07/03 2016

v0.2.2

0.2.2.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

05/12 2015

v0.2.1

0.2.1.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

05/11 2015

v0.2.0

0.2.0.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

31/08 2015

v0.1.5

0.1.5.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

30/06 2015

v0.1.4

0.1.4.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

01/05 2015

v0.1.3

0.1.3.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

10/04 2015

v0.1.2

0.1.2.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

07/04 2015

v0.1.1

0.1.1.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php

20/03 2015

v0.1.0

0.1.0.0

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

  Sources   Download

MIT

The Requires

 

The Development Requires

rabbitmq queue message messaging react amqp exchange queueing rabbit reactphp bunny react-php