2017 © Pedro PelĂĄez
 

library php-queue

a php client for message queue

image

dudashuang/php-queue

a php client for message queue

  • Monday, July 9, 2018
  • by dudashuang
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • 333 % Grown

The README.md

php-queue

, (*1)

A php client for message queue which is one of RabbitMQ, Kafka and Redis., (*2)

Requirement

Install

  • composer, (*8)

    composer require dudashuang/php-queue
    

Base Usage

  • examples, (*9)

  • create a driver, (*10)

    • redis:
    <?php
    require __DIR__ . '/vendor/autoload.php';
    
    $connector  = new Lily\Connectors\RedisConnector([
        'scheme'             => 'tcp',
        'host'               => '127.0.0.1',
        'port'               => 6379,
        'read_write_timeout' => 0,
    ]);
    $driver = new Lily\Drivers\Redis($connector);
    
    • kafka:
    <?php
    require __DIR__ . '/vendor/autoload.php';
    
    $connector  = new Lily\Connectors\KafkaConnector([
        'brokers' => [
            ['host' => 'localhost', 'port' => 9092],
        ],
    ]);
    $driver = new Lily\Drivers\Kafka($connector);
    
    • rabbitmq:
    <?php
    require __DIR__ . '/vendor/autoload.php';
    
    $connector  = new Lily\Connectors\RabbitMQConnector([
        'host'     => 'localhost',
        'port'     => 5672,
        'username' => 'guest',
        'password' => 'guest',
    ]);
    $driver = new Lily\Drivers\RabbitMQ($connector);
    
  • create a application, (*11)

    <?php
    require __DIR__ . '/vendor/autoload.php';
    
    $application = new Lily\Application($driver, [
        'deafult_queue' => 'default-queue',
        'failed_queue'  => 'failed-queue',
    ]);
    
  • dispatch a job, (*12)

    • default queue
    for ($i=0; $i<10; $i++) {
        $application->dispatch(new TestJob('hello', new LilyTest\TestModel(1, 2)));
    }
    
    • other queue
    $application->dispatch((new TestJob(...))->set_queue($queue_name));
    
  • dispatch a event, (*13)

    $application->dispatch(new TestEvent(...));
    
  • create a consumer, (*14)

    $application−>consume($queue_name);
    
  • create a listener, (*15)

    $application->listen('LilyTest\Listeners\SendListener', ['TestEvent', 'TestEvent1']);
    

TODO

  • add RocketMQ driver, (*16)

  • add delay queue, (*17)

Additional

you can use supervisor to manage consumer, (*18)

  • install, (*19)

    sudo apt-get install supervisor
    
  • supervisor config, (*20)

    sudo vim /etc/supervisor/conf.d/guopika.config
    
    [program:guopika-worker]
    process_name=%(program_name)s_%(process_num)02d
    command=php /path_to_listen_queue/cli_func
    autostart=true
    autorestart=true
    user=www-data
    numprocs=4
    redirect_stderr=true
    stdout_logfile=/path/worker.log
    

The Versions

09/07 2018

dev-master

9999999-dev

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

09/07 2018

v1.2.0

1.2.0.0

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

28/06 2018

v1.1.1

1.1.1.0

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

28/06 2018

v1.1.0

1.1.0.0

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

22/06 2018

v1.0.5

1.0.5.0

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

22/06 2018

v1.0.4

1.0.4.0

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

22/06 2018

v1.0.3

1.0.3.0

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

22/06 2018

v1.0.2

1.0.2.0

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

22/06 2018

v1.0.1

1.0.1.0

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

22/06 2018

v1.0.0

1.0.0.0

a php client for message queue

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

22/06 2018

dev-add-license-1

dev-add-license-1

a simple libraries for working with event and task queues.

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

30/05 2018

v0.5.3

0.5.3.0

a simple libraries for working with event and task queues.

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

30/05 2018

v0.5.2

0.5.2.0

a simple libraries for working with event and task queues.

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

30/05 2018

v0.5.1

0.5.1.0

a simple libraries for working with event and task queues.

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang

30/05 2018

v0.5.0

0.5.0.0

a simple libraries for working with event and task queues.

  Sources   Download

MIT

The Requires

 

by Avatar dudashuang