2017 © Pedro Peláez
 

symfony-bundle command-bus-bundle

rezzza/command-bus integration to Symfony

image

rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  • Friday, July 7, 2017
  • by steph_py
  • Repository
  • 8 Watchers
  • 5 Stars
  • 20,214 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 1 Open issues
  • 13 Versions
  • 5 % Grown

The README.md

RezzzaCommandBusBundle

Integration of the CommandBus library into Symfony2., (*1)

Installation

Require rezzza/command-bus-bundle to your composer.json file:, (*2)

{
    "require": {
        "rezzza/command-bus-bundle": "~2.0"
    }
}

Register the bundle in app/AppKernel.php:, (*3)

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Rezzza\CommandBusBundle\RezzzaCommandBusBundle()
    );
}

Update your config.yml:, (*4)

framework:
    serializer:
        enabled: true

Usage


$bus = $container->get('rezzza_command_bus.command_bus.synchronous'); // synchronous is the name you given to your bus in configuration. $bus->handle(new FooCommand());

Bus

Direct, SncRedis & OldSoundRabbit are currently supported., (*5)

Commands

Commands must inherit from Rezzza\CommandBus\Domain\CommandInterface., (*6)

Register a command handler:, (*7)

<service id="...." class="....">
    <tag name="rezzza_command_bus.command_handler" command="FQCN\MyFirstActionCommand" /> <!-- when handle this command, method `myFirstAction` will be handled. -->
    <tag name="rezzza_command_bus.command_handler" command="FQCN\MySecondActionCommand" method="myMethod" />
</service>

Events

Events:, (*8)

- on_consumer_response
- pre_handle_command

Register a listener:, (*9)

<service id="service_id" class="Foo">
    <tag name="rezzza_command_bus.event_listener" event="pre_handle_command" method="onPreHandleCommand" />
    <tag name="rezzza_command_bus.event_listener" event="on_consumer_response" method="onConsumerResponse" />
</service>

Fail Strategy

See command-bus documentation., (*10)

Console Command

A Symfony console command is provided in this bundle, (*11)

$ app/console rezzza:command_bus:consume "CommandToConsume"

Options available:

 --consumer             Which consumer should we use ? (default: "default")
 --iteration-limit (-i) Limit of iterations, -1 for infinite.. (default: -1)
 --time-limit           During how many time this command will listen to the queue. (default: 60)
 --usleep               Micro seconds (default: 100000)
 --lock                 Only one command processing ?

To watch activity of your consumer, you should register a console handler for monolog, (*12)

monolog:
    handlers:
        console:
            type:   console
            verbosity_levels:
                VERBOSITY_NORMAL: NOTICE

Configuration

rezzza_command_bus:
    buses:
      synchronous: direct
      asynchronous:
        rabbitmq:
          #define producer_guesser which allow to determine rigth producer for each command
          #producer name and command class name must be indentical
            #example:
            #producer name : source_entry_update
            #command class name : SourceEntryUpdateCommand
          producer_guesser: rezzza_command_bus.old_sound_rabbit.producer_guesser
          consumer_bus: synchronous #consumer handle command with synchronous bus
        snc_redis:
            client: default # snc redis client.
            read_block_timeout: 1 # see blpop documentation
            consumers:
                default:
                    bus: synchronous
                    fail_strategy:
                        retry_then_fail: # When the command fail, it uses this strategy.
                        # you could use too requeue, none, service.
                            attempts: 10
                            requeue_on_fail: true
    handlers: # Do you want to use handlers provided in this bundle ?
        retry:  synchronous  # If you used retry_then_fail strategy, this handler is linked to Retry commands.
        failed: synchronous # If you used retry_then_fail strategy, this handler is linked to Failed commands.

Usage with JMS Serializer

rezzza_command_bus:
    logger_normalizer: symfony_serializer

services:
    symfony_serializer:
        class: "Symfony\Component\Serializer\Serializer"

The Versions

07/07 2017

dev-master

9999999-dev https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

07/07 2017

3.3.3

3.3.3.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

11/01 2017

3.3.2

3.3.2.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

11/01 2017

3.3.1

3.3.1.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

05/01 2017

3.3.0

3.3.0.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

20/12 2016

3.2.0

3.2.0.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

08/09 2016

v3.1.0

3.1.0.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

22/02 2016

v3.0.0

3.0.0.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

12/02 2016

v2.0.1

2.0.1.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

15/01 2016

v2.0

2.0.0.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

18/12 2015

v1.0.2

1.0.2.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

11/12 2015

v1.0.1

1.0.1.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus

06/10 2015

v1.0.0

1.0.0.0 https://github.com/rezzza/command-bus-bundle

rezzza/command-bus integration to Symfony

  Sources   Download

MIT

The Requires

 

command bundle bus