Description
Symfony version(s) affected: <=4.3.0
Description
Messages coming from non-symfony producers are rejected by the messenger:consume
command:
2019-05-30T16:12:46+00:00 [warning] Message will not be retried because the SentStamp is missing and so the target sender cannot be determined.
2019-05-30T16:12:46+00:00 [critical] Rejecting App\Message\Foo (removing from transport).
The error is a result of the Symfony\Component\Messenger\Exception\InvalidArgumentException
thrown by RoutableMessageBus
:
Envelope is missing a BusNameStamp and no fallback message bus is configured on RoutableMessageBus.
My expectation was the message would be routed to the fallback message bus.
How to reproduce
Publish a message outside of Symfony (i.e. from another system, or directly with RabbitMQ admin interface).
Run the messenger:consume
command without specifying the --bus
option.
Possible Solution
Either pass the routable message bus which is already registered on the service container, or pass the default message bus to the routable message bus that's created in the ConsumeMessagesCommand
.
Additional context
The routable message bus is created directly by the ConsumeMessagesCommand
:
symfony/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php
Lines 180 to 184 in 94fd42c
It's inconsistent with the way the message bus is registered on the container:
symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.xml
Lines 107 to 111 in 2c9a196