2017 © Pedro Peláez
 

library queue-wrapper

My first Composer project

image

danikdantist/queue-wrapper

My first Composer project

  • Wednesday, July 6, 2016
  • by danikdantist
  • Repository
  • 2 Watchers
  • 1 Stars
  • 388 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 6 % Grown

The README.md

Install, (*1)

composer require danikdantist/queue-wrapper

If you want to use Kafka, you need kafka lib https://github.com/edenhill/librdkafka and rdkafka extension for php https://github.com/arnaud-lb/php-rdkafka, (*2)

You can use dockerfile to create docker image where librdkafka and PHP kafka extension already installed: https://github.com/danikdantist/Dockerfiles/blob/master/php/php5-fpm-nginx-kafka/Dockerfile, (*3)

Consumer usage:, (*4)

<?php

class Receiver implements DanikDantist\QueueWrapper\Interfaces\iReceivable
{
    public function receiveMessage(DanikDantist\QueueWrapper\Message $message)
    {
        echo $message->toString()."\n";
    }
}

class EchoLogger implements DanikDantist\QueueWrapper\Interfaces\iLogable
{
    public function info($info)
    {
        echo 'Info: '.$info."\n";
    }

    public function error($error)
    {
        echo 'Error: '.$error."\n";
    }
}

$config = new DanikDantist\QueueWrapper\Drivers\Kafka\Config();
$config
    ->setGroup('my_group')
    ->addBroker('172.17.0.31:9092')
    ->addTopic('my-test-topic')
    ->addTopic('my-test-topic-2')
;

$demon = new DanikDantist\QueueWrapper\Manager(new DanikDantist\QueueWrapper\Drivers\Kafka\Connector($config, new EchoLogger()));
$demon->addReceiver(new Receiver());
$demon->listenMessage();

Producer usage:, (*5)

<?php

class EchoLogger implements DanikDantist\QueueWrapper\Interfaces\iLogable
{
    public function info($info)
    {
        echo 'Info: '.$info."\n";
    }

    public function error($error)
    {
        echo 'Error: '.$error."\n";
    }
}

$config = new DanikDantist\QueueWrapper\Drivers\Kafka\Config();
$config->addBroker('172.17.0.31:9092');

$demon = new DanikDantist\QueueWrapper\Manager(new DanikDantist\QueueWrapper\Drivers\Kafka\Connector($config, new EchoLogger()));

$demon->sendMessage(new DanikDantist\QueueWrapper\Message('My test message', 'my-test-topic'));

The Versions

06/07 2016

dev-master

9999999-dev

My first Composer project

  Sources   Download

The Requires

  • php >=5.5.9

 

wrapper queue rdkafka

06/07 2016

0.0.4

0.0.4.0

My first Composer project

  Sources   Download

The Requires

  • php >=5.5.9

 

wrapper queue rdkafka

03/07 2016

0.0.3

0.0.3.0

My first Composer project

  Sources   Download

The Requires

  • php >=5.5.9

 

wrapper queue rdkafka

04/06 2016

0.0.1

0.0.1.0

My first Composer project

  Sources   Download

The Requires

  • php >=5.5.9

 

wrapper queue rdkafka