2017 © Pedro Peláez
 

library nette-rabbitmq

image

dada-amater/nette-rabbitmq

  • Monday, July 9, 2018
  • by dada-amater
  • Repository
  • 0 Watchers
  • 0 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 26 Versions
  • 0 % Grown

The README.md

Latest Stable Version License Total Downloads, (*1)

Nette RabbitMQ

Nette extension for RabbitMQ (using composer package jakubkulhan/bunny), (*2)

Example setup

Downloading composer package

composer require gamee/nette-rabbitmq

Extension registration

config.neon:, (*3)

extensions:
    rabbitmq: Gamee\RabbitMQ\DI\RabbitMQExtension

Example configuration

services:
    - TestConsumer

rabbitmq:
    connections:
        default:
            user: guest
            password: guest
            host: localhost
            port: 5672

    queues:
        testQueue:
            connection: default

    exchanges:
        testExchange:
            connection: default
            type: fanout
            queueBindings:
                testQueue:
                    routingKey: testRoutingKey

    producers:
        testProducer:
            exchange: testExchange
            # queue: testQueue
            contentType: application/json
            deliveryMode: 2 # Producer::DELIVERY_MODE_PERSISTENT

    consumers:
        testConsumer:
            queue: testQueue
            callback: [@TestConsumer, consume]
            qos:
                prefetchSize: 0
                prefetchCount: 5

Publishing messages

Note: Queue will be created automatically after publishing first message., (*4)

services.neon:, (*5)

services:
    - TestQueue(@Gamee\RabbitMQ\Client::getProducer(testProducer))

TestQueue.php:, (*6)

<?php

declare(strict_types=1);

use Gamee\RabbitMQ\Producer\Producer;

final class TestQueue
{

    /**
     * @var Producer
     */
    private $testProducer;


    public function __construct(Producer $testProducer)
    {
        $this->testProducer = $testProducer;
    }


    public function publish(string $message): void
    {
        $json = json_encode(['message' => $message]);
        $headers = [];

        $this->testProducer->publish($json, $headers);
    }

}

Consuming messages

Your consumer callback has to return a confirmation that particular message has been acknowledges (or different states - unack, reject)., (*7)

TestConsumer.php, (*8)

<?php

declare(strict_types=1);

use Bunny\Message;
use Gamee\RabbitMQ\Consumer\IConsumer;

final class TestConsumer implements IConsumer
{

    public function consume(Message $message): int
    {
        $messageData = json_decode($message->content);

        $headers = $message->headers;

        /**
         * @todo Some logic here...
         */

        return IConsumer::MESSAGE_ACK; // Or ::MESSAGE_NACK || ::MESSAGE_REJECT
    }

}

Running a consumer trough CLI

There are two consumer commands prepared. rabbitmq:consumer wiil consume messages for specified amount of time (in seconds). Following command wiil be consuming messages for one hour:, (*9)

php index.php rabbitmq:consumer testConsumer 3600

rabbitmq:staticConsumer will consume particular amount of messages. Following example will consume just 20 messages:, (*10)

php index.php rabbitmq:staticConsumer testConsumer 20

The Versions

09/07 2018

dev-disable-autocreation

dev-disable-autocreation https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

The Development Requires

extension php rabbitmq nette rabbit bunny bunnyphp

09/07 2018

dev-master

9999999-dev https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

The Development Requires

extension php rabbitmq nette rabbit bunny bunnyphp

09/07 2018
04/06 2018

dev-persistent-connetions

dev-persistent-connetions https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

The Development Requires

extension php rabbitmq nette rabbit bunny bunnyphp

21/05 2018
18/05 2018

v1.3.3

1.3.3.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

01/05 2018

v1.3.2

1.3.2.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

22/03 2018

v1.3.1

1.3.1.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

02/03 2018

v1.3.0

1.3.0.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

19/02 2018

v1.2.10

1.2.10.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

08/02 2018

v1.2.9

1.2.9.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

12/12 2017

v1.2.8

1.2.8.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

12/12 2017

v1.2.7

1.2.7.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

28/11 2017

v1.2.6

1.2.6.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

15/08 2017

v1.2.5

1.2.5.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

14/07 2017

v1.2.4

1.2.4.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

13/07 2017

v1.2.3

1.2.3.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

12/07 2017

v1.2.2

1.2.2.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

11/07 2017

v1.2.1

1.2.1.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

extension php rabbitmq nette rabbit bunny bunnyphp

11/07 2017

v1.2.0

1.2.0.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

The Development Requires

extension php rabbitmq nette rabbit bunny bunnyphp

22/06 2017

v1.1.0

1.1.0.0 https://github.com/gameeapp/nette-rabbitmq

  Sources   Download

MIT

The Requires

 

The Development Requires

extension php rabbitmq nette rabbit bunny bunnyphp