dev-master
9999999-dev https://github.com/wildpascal/remote-event-dispatcherRemoteEventDispatcher for communicating between multiple systems.
MIT
The Requires
- php >=5.5.0
The Development Requires
by Pascal Wild
Wallogit.com
2017 © Pedro Peláez
RemoteEventDispatcher for communicating between multiple systems.
RemoteEventDispatcher for communicating between multiple systems., (*2)
Require the bundle and its dependencies with composer:, (*3)
$ composer require wildpascal/remote-event-dispatcher
Transport for Events. Possible Handlers: - AmqpHandler (Handler to send Events via a queue which is implementing the Amqp protocol), (*4)
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);
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();
This bundle is under the MIT license. See the complete license in the bundle:, (*9)
Resources/meta/LICENSE
RemoteEventDispatcher for communicating between multiple systems.
MIT