-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing a bug when "async_switch" option is used. #65
Conversation
Pull Request Test Coverage Report for Build 212
💛 - Coveralls |
I did not use the async switch, but it looks good to me 👍 Do you think you can add a test case for it? The other error is not related to this PR. Feel free to look at it if you want, otherwise I will do. Also: Is there anything that prevents the usage of |
@UFOMelkor i've added test cases and replaced try-catch by |
The failures in CI have other reasons, will be fixed with #67 . The bug just appears if the handlers are registered with tags. I had a look at it and modified as following. prooph_service_bus:
command_buses:
command_bus_async:
router:
async_switch: async_message_producer
services:
Acme\RegisterUserHandler:
class: ProophTest\Bundle\ServiceBus\DependencyInjection\Fixture\Model\AcmeRegisterUserHandler
public: true
tags: [{name: 'prooph_service_bus.command_bus_async.route_target', message_detection: true }]
async_message_producer:
class: ProophTest\Bundle\ServiceBus\DependencyInjection\Fixture\Model\AsyncMessageProducer
public: true /**
* @test
*/
public function it_creates_a_command_bus_with_async_switch_message_router()
{
$container = $this->loadContainer('command_bus_async', new PluginsPass(), new RoutePass());
/** @var AsyncMessageProducer $asyncMessageProducer */
$asyncMessageProducer = $container->get('async_message_producer');
/** @var CommandBus $commandBus */
$commandBus = $container->get('prooph_service_bus.command_bus_async');
/** @var AcmeRegisterUserHandler $handler */
$handler = $container->get('Acme\RegisterUserHandler');
// dispatch an async command
$commandBus->dispatch(new AsyncAcmeRegisterUserCommand([]));
self::assertInstanceOf(AsyncAcmeRegisterUserCommand::class, $asyncMessageProducer->lastMessage);
// dispatch an sync command
$commandBus->dispatch(new AcmeRegisterUserCommand([]));
self::assertInstanceOf(AcmeRegisterUserCommand::class, $handler->lastCommand());
} |
@UFOMelkor I've made a mistake in fixtures for event bus. Now it covers the issue. |
@UFOMelkor i've decided to remove event_bus_async fixtures, so now only command_bus_async fixture is changed |
Would be great 👍 |
@UFOMelkor Done, could you check? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one space missing, then we are ready :-)
@@ -42,7 +42,12 @@ public function process(ContainerBuilder $container) | |||
$buses = $container->getParameter('prooph_service_bus.' . $type . '_buses'); | |||
|
|||
foreach ($buses as $name => $bus) { | |||
$router = $container->findDefinition(sprintf('prooph_service_bus.%s.router', $name)); | |||
$routerServiceId = sprintf('prooph_service_bus.%s.decorated_router', $name); | |||
if (!$container->has($routerServiceId)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after !
done, thx |
👍 |
Thank you! 🎉 |
When "async_switch" option is used "$routerArguments" should be passed to the decorated router, but not to the decorator.