[Messenger] Added support for from_transport
attribute on messenger.message_handler
tag
This commit is contained in:
parent
dc8d470752
commit
c965e4e844
@ -9,6 +9,7 @@ CHANGELOG
|
||||
* Added support for auto trimming of Redis streams.
|
||||
* `InMemoryTransport` handle acknowledged and rejected messages.
|
||||
* Made all dispatched worker event classes final.
|
||||
* Added support for `from_transport` attribute on `messenger.message_handler` tag.
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
@ -109,6 +109,10 @@ class MessengerPass implements CompilerPassInterface
|
||||
$options = ['method' => $options];
|
||||
}
|
||||
|
||||
if (!isset($options['from_transport']) && isset($tag['from_transport'])) {
|
||||
$options['from_transport'] = $tag['from_transport'];
|
||||
}
|
||||
|
||||
$priority = $tag['priority'] ?? $options['priority'] ?? 0;
|
||||
$method = $options['method'] ?? '__invoke';
|
||||
|
||||
|
@ -78,6 +78,25 @@ class MessengerPassTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testFromTransportViaTagAttribute()
|
||||
{
|
||||
$container = $this->getContainerBuilder($busId = 'message_bus');
|
||||
$container
|
||||
->register(DummyHandler::class, DummyHandler::class)
|
||||
->addTag('messenger.message_handler', ['from_transport' => 'async'])
|
||||
;
|
||||
|
||||
(new MessengerPass())->process($container);
|
||||
|
||||
$handlersLocatorDefinition = $container->getDefinition($busId.'.messenger.handlers_locator');
|
||||
$this->assertSame(HandlersLocator::class, $handlersLocatorDefinition->getClass());
|
||||
|
||||
$handlerDescriptionMapping = $handlersLocatorDefinition->getArgument(0);
|
||||
$this->assertCount(1, $handlerDescriptionMapping);
|
||||
|
||||
$this->assertHandlerDescriptor($container, $handlerDescriptionMapping, DummyMessage::class, [DummyHandler::class], [['from_transport' => 'async']]);
|
||||
}
|
||||
|
||||
public function testProcessHandlersByBus()
|
||||
{
|
||||
$container = $this->getContainerBuilder($commandBusId = 'command_bus');
|
||||
|
Reference in New Issue
Block a user