m12u/amqp-bundle

AMQP client consumer Bundle for Symfony 3

Installs: 216

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 1

Type:symfony-bundle

1.0.0 2017-07-15 12:46 UTC

This package is not auto-updated.

Last update: 2024-11-19 18:10:58 UTC


README

Command

$ bin/console m12u:amqp-stream:consumer --host=[HOST] --username=[USERNAME] --queue=[QUEUE] --port=[POST] <--vhost=[VHOST]> <--ssl>

Events availables

Create listener

First step, create class

<?php

namespace AppBundle\Listener;

use stdClass;
use M12U\Bundle\AmqpBundle\Event\AMQPMessageEventInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
 * Class AMQPMessageListener
 * @package AppBundle\Listener
 */
class AMQPMessageListener
{
    /**
     * @param AMQPMessageEventInterface $event
     */
    public function onM12uAmqpMessage(AMQPMessageEventInterface $event)
    {
        // exemple ...
        
        $message = $event->getMessage();
        switch ($event->getQueue())
        {
            case '1234567890987654321':
                // todo ...
                // operation on $message
                break;
            case '0987654321234567890':
                // todo ...
                // operation on $message
                break;
        }
    }
}

Last step, declare service

# app/config/services.yml
services:
    AppBundle\Listener\AMQPMessageListener:
        tags:
            - { name: kernel.event_listener, event: m12u.amqp.message }