8000 bug #59198 [Messenger] Filter out non-consumable receivers when regis… · symfony/framework-bundle@078a6f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 078a6f1

Browse files
committed
bug #59198 [Messenger] Filter out non-consumable receivers when re 8000 gistering ConsumeMessagesCommand (wazum)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [Messenger] Filter out non-consumable receivers when registering `ConsumeMessagesCommand` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #51556 | License | MIT This pull request enhances the `MessengerPass` in the Symfony Framework Bundle to automatically filter out non-consumable receivers when registering the `ConsumeMessagesCommand`. The key changes are: The FrameworkExtension has been updated to mark the "sync" transport as non-consumable by default, without requiring the user to explicitly set the `is_consumable` attribute. The `MessengerPass` then checks the `is_consumable` attribute on the `messenger.receiver` tags. If the attribute is set to `false`, the receiver is considered non-consumable and will not be added to the list of receivers for the consume command. If there is only one consumable receiver, the consume command will automatically use that receiver without prompting the user to select one (I added this as a separate commit if this is too implicit). These changes improve the user experience by removing unnecessary (and non-functioning) options. This is my first pull request for the _Symfony_ project, so please let me know what I can improve. Commits ------- 34c7e6f1902 [Messenger] Filter out non-consumable receivers when registering `ConsumeMessagesCommand`
2 parents 33b50cb + c796e22 commit 078a6f1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,13 +2282,17 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
22822282
$transportRateLimiterReferences = [];
22832283
foreach ($config['transports'] as $name => $transport) {
22842284
$serializerId = $transport['serializer'] ?? 'messenger.default_serializer';
2285+
$tags = [
2286+
'alias' => $name,
2287+
'is_failure_transport' => \in_array($name, $failureTransports),
2288+
];
2289+
if (str_starts_with($transport['dsn'], 'sync://')) {
2290+
$tags['is_consumable'] = false;
2291+
}
22852292
$transportDefinition = (new Definition(TransportInterface::class))
22862293
->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
22872294
->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
2288-
->addTag('messenger.receiver', [
2289-
'alias' => $name,
2290-
'is_failure_transport' => \in_array($name, $failureTransports),
2291-
])
2295+
->addTag('messenger.receiver', $tags)
22922296
;
22932297
$container->setDefinition($transportId = 'messenger.transport.'.$name, $transportDefinition);
22942298
$senderAliases[$name] = $transportId;

0 commit comments

Comments
 (0)
0