2017 © Pedro Peláez
 

library remote-event-dispatcher

RemoteEventDispatcher for communicating between multiple systems.

image

wildpascal/remote-event-dispatcher

RemoteEventDispatcher for communicating between multiple systems.

  • Thursday, May 5, 2016
  • by wildpascal
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Remote Event Dispatcher

Build Status Total Downloads Latest Stable Version, (*1)

RemoteEventDispatcher for communicating between multiple systems., (*2)

Installation

Require the bundle and its dependencies with composer:, (*3)

$ composer require wildpascal/remote-event-dispatcher

Handler

Transport for Events. Possible Handlers: - AmqpHandler (Handler to send Events via a queue which is implementing the Amqp protocol), (*4)

Dispatch Events

To dispatch events you have to configure the RemoteEventDispatcher. The RemoteEventDispatcher requires a Handler., (*5)

You can dispatch every event which extends the AbstractEvent., (*6)

// Configuration for RabbitMQ or any other queue which is based on AMQP protocol
$queueName = 'remote_event_dispatcher';
$config = [
    'host' => 'localhost',
];
$connection = new \PhpAmqpLib\Connection\AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();

// Configure AmqpHandler
$handler = new \WP\RemoteEventDispatcher\Handler\Amqp\AmqpHandler($channel, $queueName);

// Setup RemoteEventDispatcher with AmqpHandler
$remoteEventDispatcher = new \WP\RemoteEventDispatcher\EventDispatcher\RemoteEventDispatcher($handler);

$printHalloEvent = new \WP\RemoteEventDispatcher\Model\MutableEvent('printHalloEvent');
$printTestEvent = new \WP\RemoteEventDispatcher\Model\MutableEvent('printTestEvent');

$remoteEventDispatcher->dispatch($printHalloEvent);
$remoteEventDispatcher->dispatch($printTestEvent);

Listen for Events

To Listen for Events you have to configure the RemoteEventListener. The RemoteEventListener requires a Handler and a EventStrategy., (*7)

You also can use a EventStrategyRegistry to register different EventStrategies based on the eventName to implement a logic based on Events, (*8)

// Configuration for RabbitMQ or any other queue which is based on AMQP protocol
$queueName = 'remote_event_dispatcher';
$config = [
    'host' => 'localhost',
];
$connection = new \PhpAmqpLib\Connection\AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();

// Configure AmqpHandler
$handler = new \WP\RemoteEventDispatcher\Handler\Amqp\AmqpHandler($channel, $queueName);

// Setup your custom EventStrategy
$eventStrategy = new YourCustomEventStrategy();

// Setup RemoteEventListener with AmqpHandler
$remoteEventListener = new \WP\RemoteEventDispatcher\EventListener\RemoteEventListener($handler, $eventStrategy);
$remoteEventListener->listen();

License

This bundle is under the MIT license. See the complete license in the bundle:, (*9)

Resources/meta/LICENSE

The Versions

05/05 2016

dev-master

9999999-dev https://github.com/wildpascal/remote-event-dispatcher

RemoteEventDispatcher for communicating between multiple systems.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Pascal Wild