From 67f3f7673256f1fa533cc2bfdccfadad71b0cd57 Mon Sep 17 00:00:00 2001 From: Denis Brumann Date: Fri, 7 Jun 2019 20:21:16 +0200 Subject: [PATCH 1/2] Warn about multiple handlers. When using tags and autoconfigure you might end up with multiple handlers being registered to a bus. See symfony/symfony#31909 --- messenger/multiple_buses.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/messenger/multiple_buses.rst b/messenger/multiple_buses.rst index 28d859dd6dd..515c32a0739 100644 --- a/messenger/multiple_buses.rst +++ b/messenger/multiple_buses.rst @@ -197,6 +197,14 @@ you can restrict each handler to a specific bus using the ``messenger.message_ha This way, the ``App\MessageHandler\SomeCommandHandler`` handler will only be known by the ``messenger.bus.commands`` bus. +.. tip:: + + If you manually restrict handlers be sure to have ``autoconfigure`` disabled, + or not implement the ``Symfony\Component\Messenger\MessageHandlerInterface`` + as this might cause your handler to be registered twice. + + See :ref:`autoconfigure ` for more information. + You can also automatically add this tag to a number of classes by following a naming convention and registering all of the handler services by name with the correct tag: From f83e176f617ce1009efbacc2d126765eab83a079 Mon Sep 17 00:00:00 2001 From: Denis Brumann Date: Sat, 8 Jun 2019 12:47:52 +0200 Subject: [PATCH 2/2] Fixes namespace for MessageHandlerInterface --- messenger/multiple_buses.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger/multiple_buses.rst b/messenger/multiple_buses.rst index 515c32a0739..7b4447e9f55 100644 --- a/messenger/multiple_buses.rst +++ b/messenger/multiple_buses.rst @@ -200,7 +200,7 @@ known by the ``messenger.bus.commands`` bus. .. tip:: If you manually restrict handlers be sure to have ``autoconfigure`` disabled, - or not implement the ``Symfony\Component\Messenger\MessageHandlerInterface`` + or not implement the ``Symfony\Component\Messenger\Handler\MessageHandlerInterface`` as this might cause your handler to be registered twice. See :ref:`autoconfigure ` for more information.