8000 [Messenger] Added support for `from_transport` attribute on `messenge… · symfony/symfony@c965e4e · GitHub
[go: up one dir, main page]

Skip to content

Commit c965e4e

Browse files
ruudkfabpot
authored andcommitted
[Messenger] Added support for from_transport attribute on messenger.message_handler tag
1 parent dc8d470 commit c965e4e

File tree

3 files changed

+24
-0
lines changed
  • src/Symfony/Component/Messenger
  • Tests/DependencyInjection
  • 3 files changed

    +24
    -0
    lines changed

    src/Symfony/Component/Messenger/CHANGELOG.md

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -9,6 +9,7 @@ CHANGELOG
    99
    * Added support for auto trimming of Redis streams.
    1010
    * `InMemoryTransport` handle acknowledged and rejected messages.
    1111
    * Made all dispatched worker event classes final.
    12+
    * Added support for `from_transport` attribute on `messenger.message_handler` tag.
    1213

    1314
    4.3.0
    1415
    -----

    src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -109,6 +109,10 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
    109109
    $options = ['method' => $options];
    110110
    }
    111111

    112+
    if (!isset($options['from_transport']) && isset($tag['from_transport'])) {
    113+
    $options['from_transport'] = $tag['from_transport'];
    114+
    }
    115+
    112116
    $priority = $tag['priority'] ?? $options['priority'] ?? 0;
    113117
    $method = $options['method'] ?? '__invoke';
    114118

    src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php

    Lines changed: 19 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -78,6 +78,25 @@ public function testProcess()
    7878
    );
    8000 7979
    }
    8080

    81+
    public function testFromTransportViaTagAttribute()
    82+
    {
    83+
    $container = $this->getContainerBuilder($busId = 'message_bus');
    84+
    $container
    85+
    ->register(DummyHandler::class, DummyHandler::class)
    86+
    ->addTag('messenger.message_handler', ['from_transport' => 'async'])
    87+
    ;
    88+
    89+
    (new MessengerPass())->process($container);
    90+
    91+
    $handlersLocatorDefinition = $container->getDefinition($busId.'.messenger.handlers_locator');
    92+
    $this->assertSame(HandlersLocator::class, $handlersLocatorDefinition->getClass());
    93+
    94+
    $handlerDescriptionMapping = $handlersLocatorDefinition->getArgument(0);
    95+
    $this->assertCount(1, $handlerDescriptionMapping);
    96+
    97+
    $this->assertHandlerDescriptor($container, $handlerDescriptionMapping, DummyMessage::class, [DummyHandler::class], [['from_transport' => 'async']]);
    98+
    }
    99+
    81100
    public function testProcessHandlersByBus()
    82101
    {
    83102
    $container = $this->getContainerBuilder($commandBusId = 'command_bus');

    0 commit comments

    Comments
     (0)
    0