2017 © Pedro Peláez
 

symfony-bundle service-bus-lite-bundle

ServiceBus bundle implementation in Symfomy2

image

psamatt/service-bus-lite-bundle

ServiceBus bundle implementation in Symfomy2

  • Tuesday, February 4, 2014
  • by psamatt
  • Repository
  • 1 Watchers
  • 4 Stars
  • 1,639 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 8 % Grown

The README.md

Service Bus Bundle

Bundle that integrates Service Bus into Symfony2 through a bundle., (*1)

Installation using Composer

This bundle can be installed using composer by adding the following in the require section of your composer.json file:, (*2)

    "require": {
        ...
        "psamatt/service-bus-lite-bundle": "*"
    },

Then, enable the bundle in the AppKernel:, (*3)


<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Psamatt\ServiceBusLiteBundle\PsamattServiceBusLiteBundle(), ); }

How to use

Create Query or Command Handlers that implement ServiceBus\IQueryHandler or ServiceBus\ICommandHandler respectively such as:, (*4)

use \ServiceBus\ICommand;

class FooCommandHandler implements \ServiceBus\ICommandHandler
{
    function handle(ICommand $command)
    {

    }
}

Then register the Handler as a service, tagged as a ServiceBus Handler in services.yml:, (*5)

services:
    # Command Handler
    foo.command.handler:
        class: Acme\HelloBundle\CommandHandler\FooCommandHandler
        tags:
            -  { name: servicebus.command_handler }

    # Query Handler 
    foo.query.handler:
        class: Acme\HelloBundle\QueryHandler\FooQueryHandler
        tags:
            -  { name: servicebus.query_handler }

Tagging this service as a command or query handler will allow the service bus to register this class as an awaiting handler for an upcoming command., (*6)

Now all you have to do is initialise a FooCommand within your Controller and send to the ServiceBus, (*7)

class FooController extends Controller
{

    public function indexAction()
    {
        // we send Commands
        $this->get('ServiceBus.Mediator')->send(new FooCommand('myEventName'));

        // we request Queries
        $response = $this->get('ServiceBus.Mediator')->request(new FooQuery('myEventName'));
    }

In the background, the ServiceBus will find the associated Handler where you would code the logic required for that specific action., (*8)

Further code example can be found in the example folder of the main repository, (*9)

Note: It is important that your Command and your CommandHandler classes have Command and CommandHandler appended to the Class name for the ServiceBus to find the related CommandHandler for a raised Command., (*10)

The Versions

04/02 2014

dev-master

9999999-dev http://github.com/psamatt/ServiceBusLiteBundle

ServiceBus bundle implementation in Symfomy2

  Sources   Download

MIT

The Requires

 

by Matt Goodwin

symfony2 bundle servicebus

04/02 2014

dev-dev

dev-dev http://github.com/psamatt/ServiceBusLiteBundle

ServiceBus bundle implementation in Symfomy2

  Sources   Download

MIT

The Requires

 

by Matt Goodwin

symfony2 bundle servicebus

27/01 2014

1.0

1.0.0.0 http://github.com/psamatt/ServiceBusLiteBundle

ServiceBus bundle implementation in Symfomy2

  Sources   Download

MIT

The Requires

 

by Matt Goodwin

symfony2 bundle servicebus