2017 © Pedro Peláez
 

symfony-bridge swarrot-bridge

Swarrot bridge for Symfony Message component

image

sroze/swarrot-bridge

Swarrot bridge for Symfony Message component

  • Sunday, October 8, 2017
  • by sroze
  • Repository
  • 0 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Swarrot Bridge for Symfony Message component

This bridge allows you to use the great designed Swarrot library to consume and produce messages to various message brokers., (*1)

Usage

  1. Install Swarrot's bridge
composer req sroze/swarrot-bridge:dev-master
  1. Configure Swarrot Bundle within your application.
# config/packages/swarrot.yaml
swarrot:
    default_connection: rabbitmq
    connections:
        rabbitmq:
            host: 'localhost'
            port: 5672
            login: 'guest'
            password: 'guest'
            vhost: '/'

    consumers:
        my_consumer:
            processor: app.message_processor
            middleware_stack:
                 - configurator: swarrot.processor.signal_handler
                 - configurator: swarrot.processor.max_messages
                   extras:
                       max_messages: 100
                 - configurator: swarrot.processor.doctrine_connection
                   extras:
                       doctrine_ping: true
                 - configurator: swarrot.processor.doctrine_object_manager
                 - configurator: swarrot.processor.exception_catcher
                 - configurator: swarrot.processor.ack

    messages_types:
        my_publisher:
            connection: rabbitmq # use the default connection by default
            exchange: my_exchange

Important note: Swarrot will not automatically create the exchanges, queues and bindings for you. You need to manually configure these within RabbitMq (or another connector you use)., (*2)

  1. Register producer and processor.
# config/services.yaml
services:
    # ...

    app.message_producer:
        class: Sam\Symfony\Bridge\SwarrotMessage\SwarrotProducer
        arguments:
        - "@swarrot.publisher"
        - "@message.transport.default_encoder"
        - my_publisher

    app.message_processor:
        class: Sam\Symfony\Bridge\SwarrotMessage\SwarrotProcessor
        arguments:
        - "@message_bus"
        - "@message.transport.default_decoder"

See that the processor is something Swarrot-specific. As Swarrot's power is to consume messages, we won't use the Message component's command in this context but Swarrot's command. We've configured Swarrot to use this processor in the previous file's configuration., (*3)

  1. Route your messages to the bus
# config/packages/framework.yaml
    message:
        routing:
            'App\Message\MyMessage': app.message_producer
  1. Consume your messages!
bin/console swarrot:consume:my_consumer queue_name_you_created

The Versions

08/10 2017

dev-master

9999999-dev http://symfony.com

Swarrot bridge for Symfony Message component

  Sources   Download

MIT

The Requires

 

symfony message swarrot