2017 © Pedro Peláez
 

yii2-extension yii2-rabbitmq

Yii2 rabbitmq

image

sansusan/yii2-rabbitmq

Yii2 rabbitmq

  • Tuesday, February 27, 2018
  • by sansusan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 120 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 8 Versions
  • 8 % Grown

The README.md

yii2-rabbitmq

Yii2 Rabbimmq, (*1)

Installation

add, (*2)

"sansusan/yii2-rabbitmq": "*"

to the require section of your composer.json file., (*3)

Used PhpAmqpLib

add component in config file, (*4)

'rabbit' => [
    'class' => 'sansusan\rabbitmq\RabbitPhpAmqpLib',
    'host' => '127.0.0.1',
    'amqpPort' => 5666,
    'login' => 'user_login',
    'pass' => 'user_pass',
    'vhost' => '/',
    'receiveQueueName' => 'receive_queue',
    'receiveWaitTimeout' => '10',
    'sendQueueName' => 'send_queue',
    'prefetchCount' => 1,
    'heartbeat' => 30,
    'read_write_timeout' => 60,
    'connection_timeout' => 3,
    'useSSL' => true,
    'caFilePath' => '/var/www/html/rabbitmq/cacert.pem',
    'autoACK' => false,
 ],

add console command, (*5)

use PhpAmqpLib\Message\AMQPMessage;
use sansusan\rabbitmq\RabbitPhpAmqpLib;

class TestController extends \yii\console\Controller
{
    private function receiveCallback(AMQPMessage $message)
    {
        $body = $message->body;
        $rabbit = \Yii::$app->rabbit;
        $rabbit->sendACK($message);
    }

    public function actionRead()
    {
        $rabbit = \Yii::$app->rabbit;
        $rabbit->receive([$this, 'receiveCallback']);
    }

    public function actionSend($message)
    {
        $rabbit = \Yii::$app->rabbit;

        // add custom heeaders
        $headers = [
            'file_name' => 'test.xml',
        ];
        $rabbit->send($message, $headers);
    }
}

Used PECL amqp lib

add component in config file, (*6)

'rabbit_pecl' => [
    'class' => 'sansusan\rabbitmq\RabbitPeclAmqp',
    'host' => '127.0.0.1',
    'amqpPort' => 5666,
    'login' => 'user_login',
    'pass' => 'user_pass',
    'vhost' => '/',
    'receiveQueueName' => 'receive_queue',
    'receiveWaitTimeout' => '10',
    'sendQueueName' => 'send_queue',
    'prefetchCount' => 1,
    'heartbeat' => 30,
    'read_write_timeout' => 60,
    'connection_timeout' => 3,
    'useSSL' => true,
    'caFilePath' => '/var/www/html/rabbitmq/cacert.pem',
    'autoACK' => false,
 ],

add console command, (*7)

use AMQPChannel;
use AMQPConnection;
use AMQPExchange;
use AMQPQueue;

class TestController extends \yii\console\Controller
{
    public function actionReadpecl()
        {
            $rabbit = \Yii::$app->rabbit_pecl;
            $message = $rabbit->receive();
            if ($message) {
                echo $message->getBody();
            }
        }

        public function actionSendpecl()
        {
            $rabbit = \Yii::$app->rabbit_pecl;
            $message = 'Hello from PECL amqp';
            $headers = [
                'some_name' => 'some_value',
            ];
            if ($rabbit->send($message, $headers))
                echo "Success\n";
        }
}

The Versions

27/02 2018

dev-master

9999999-dev

Yii2 rabbitmq

  Sources   Download

BSD-3-Clause

The Requires

 

by Eremin A.V.

rabbitmq yii2 phpamqlib phpamqp

27/02 2018

1.0.6

1.0.6.0

Yii2 rabbitmq

  Sources   Download

BSD-3-Clause

The Requires

 

by Eremin A.V.

rabbitmq yii2 phpamqlib phpamqp

27/02 2018

1.0.5

1.0.5.0

Yii2 rabbitmq

  Sources   Download

BSD-3-Clause

The Requires

 

by Eremin A.V.

rabbitmq yii2 phpamqlib phpamqp

29/05 2017

1.0.4

1.0.4.0

Yii2 rabbitmq

  Sources   Download

BSD-3-Clause

The Requires

 

by Eremin A.V.

rabbitmq yii2 phpamqlib phpamqp

29/05 2017

1.0.3

1.0.3.0

Yii2 rabbitmq

  Sources   Download

BSD-3-Clause

The Requires

 

by Eremin A.V.

rabbitmq yii2 phpamqlib phpamqp

27/02 2017

1.0.2

1.0.2.0

Yii2 rabbitmq

  Sources   Download

BSD-3-Clause

The Requires

 

by Eremin A.V.

rabbitmq yii2 phpamqlib phpamqp

10/09 2016

1.0.1

1.0.1.0

Yii2 rabbitmq

  Sources   Download

BSD-3-Clause

The Requires

 

by Eremin A.V.

rabbitmq yii2

10/09 2016

v1.0.0

1.0.0.0

Yii2 rabbitmq

  Sources   Download

BSD-3-Clause

The Requires

 

by Eremin A.V.

rabbitmq yii2