Skip to content

[WIP][Messenger][FrameworkBundle] Fix xml configuration of messenger routing #33750

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode)
->ifTrue(function ($v) { return isset($v['buses']) && \count($v['buses']) > 1 && null === $v['default_bus']; })
->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
->end()
->fixXmlConfig('routing', 'routing')
->children()
->arrayNode('routing')
->normalizeKeys(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
// make sure senderAliases contains all senders
foreach ($messageConfiguration['senders'] as $sender) {
if (!isset($senderReferences[$sender])) {
throw new LogicException(sprintf('Invalid Messenger routing configuration: the "%s" class is being routed to a sender called "%s". This is not a valid transport or service id.', $message, $sender));
throw new LogicException(sprintf('Invalid Messenger routing configuration: the "%s" class is being routed to a sender called "%s". This is not a valid transport or service ID.', $message, $sender));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
<framework:routing message-class="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage">
<framework:sender service="invalid" />
</framework:routing>
<framework:routing message-class="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\SecondMessage">
<framework:sender service="amqp" />
<framework:sender service="audit" />
</framework:routing>
<framework:transport name="amqp" dsn="amqp://localhost/%2f/messages" />
</framework:messenger>
</framework:config>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\DependencyInjection\Reference;
Expand Down Expand Up @@ -768,15 +770,15 @@ public function testMessengerWithMultipleBuses()

public function testMessengerMiddlewareFactoryErroneousFormat()
{
$this->expectException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid middleware at path "framework.messenger": a map with a single factory id as key and its arguments as value was expected, {"foo":["qux"],"bar":["baz"]} given.');
$this->createContainerFromFile('messenger_middleware_factory_erroneous_format');
}

public function testMessengerInvalidTransportRouting()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('Invalid Messenger routing configuration: the "Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage" class is being routed to a sender called "invalid". This is not a valid transport or service id.');
$this->expectException(LogicException::class);
$this->expectExceptionMessage('Invalid Messenger routing configuration: the "Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage" class is being routed to a sender called "invalid". This is not a valid transport or service ID.');
$this->createContainerFromFile('messenger_routing_invalid_transport');
}

Expand Down