-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config route option async_switch
- Loading branch information
1 parent
f97bfe9
commit 0871828
Showing
11 changed files
with
173 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* prooph (http://getprooph.org/) | ||
* | ||
* @see https://github.com/prooph/service-bus-symfony-bundle for the canonical source repository | ||
* @copyright Copyright (c) 2017 prooph software GmbH (http://prooph-software.com/) | ||
* @license https://github.com/prooph/service-bus-symfony-bundle/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Prooph\Bundle\ServiceBus; | ||
|
||
use Prooph\ServiceBus\MessageBus; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
class MessageBusFactory | ||
{ | ||
public function create(string $class, ContainerInterface $container, array $plugins = []): MessageBus | ||
{ | ||
/** @var MessageBus $bus */ | ||
$bus = new $class(); | ||
|
||
foreach ($plugins as $pluginId) { | ||
$plugin = $container->get($pluginId); | ||
$plugin->attachToMessageBus($bus); | ||
} | ||
|
||
return $bus; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/DependencyInjection/Fixture/Model/AsyncMessageProducer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ProophTest\Bundle\ServiceBus\DependencyInjection\Fixture\Model; | ||
|
||
use Prooph\Common\Messaging\Message; | ||
use Prooph\ServiceBus\Async\MessageProducer; | ||
use React\Promise\Deferred; | ||
|
||
class AsyncMessageProducer implements MessageProducer | ||
{ | ||
public function __invoke(Message $message, Deferred $deferred = null) | ||
{ | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
test/DependencyInjection/Fixture/config/xml/command_bus_async.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<srv:container xmlns="http://getprooph.org/schemas/symfony-dic/prooph" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:srv="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://getprooph.org/schemas/symfony-dic/prooph http://getprooph.org/schemas/symfony-dic/prooph/service_bus-5.1.xsd"> | ||
|
||
<config> | ||
<command_bus name="command_bus_async" message_factory="prooph_service_bus.message_factory"> | ||
<plugin>prooph_service_bus.handle_command_invoke_strategy</plugin> | ||
<router type="prooph_service_bus.command_bus_router" async_switch="async_message_producer"> | ||
<route command="Acme\RegisterUser">Acme\RegisterUserHandler</route> | ||
</router> | ||
</command_bus> | ||
</config> | ||
|
||
<srv:services> | ||
<srv:service id="Acme\RegisterUserHandler" class="ProophTest\Bundle\ServiceBus\DependencyInjection\Fixture\Model\AcmeRegisterUserHandler" /> | ||
<srv:service id="async_message_producer" class="ProophTest\Bundle\ServiceBus\DependencyInjection\Fixture\Model\AsyncMessageProducer" /> | ||
</srv:services> | ||
</srv:container> |
13 changes: 13 additions & 0 deletions
13
test/DependencyInjection/Fixture/config/yml/command_bus_async.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
prooph_service_bus: | ||
command_buses: | ||
command_bus_async: | ||
router: | ||
async_switch: 'async_message_producer' | ||
routes: | ||
'Acme\RegisterUser': 'Acme\RegisterUserHandler' | ||
|
||
services: | ||
'Acme\RegisterUserHandler': | ||
class: ProophTest\Bundle\ServiceBus\DependencyInjection\Fixture\Model\AcmeRegisterUserHandler | ||
'async_message_producer': | ||
class: ProophTest\Bundle\ServiceBus\DependencyInjection\Fixture\Model\AsyncMessageProducer |