-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Prioritize receivers via transport configuration #57757
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
base: 7.4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,6 +242,8 @@ private function registerReceivers(ContainerBuilder $container, array $busIds): | |
{ | ||
$receiverMapping = []; | ||
$failureTransportsMap = []; | ||
$receiverPriority = []; | ||
|
||
if ($container->hasDefinition('console.command.messenger_failed_messages_retry')) { | ||
$commandDefinition = $container->getDefinition('console.command.messenger_failed_messages_retry'); | ||
$globalReceiverName = $commandDefinition->getArgument(0); | ||
|
@@ -263,15 +265,23 @@ private function registerReceivers(ContainerBuilder $container, array $busIds): | |
$receiverMapping[$id] = new Reference($id); | ||
|
||
foreach ($tags as $tag) { | ||
$receiverPriority[$id] = max($tag['priority'] ?? 0, $receiverPriority[$id] ?? PHP_INT_MIN); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it happen that a receiver service has multiple Based on the current There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not using PriorityTaggedServiceTrait::findAndSortTaggedServices instead? |
||
|
||
if (isset($tag['alias'])) { | ||
$receiverMapping[$tag['alias']] = $receiverMapping[$id]; | ||
$receiverPriority[$tag['alias']] = max($tag['priority'] ?? 0, $receiverPriority[$tag['alias']] ?? PHP_INT_MIN); | ||
|
||
if ($tag['is_failure_transport'] ?? false) { | ||
$failureTransportsMap[$tag['alias']] = $receiverMapping[$id]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
$prioritySorter = fn (string $a, string $b): int => $receiverPriority[$b] <=> $receiverPriority[$a]; | ||
uksort($receiverMapping, $prioritySorter); | ||
uksort($failureTransportsMap, $prioritySorter); | ||
|
||
$receiverNames = []; | ||
foreach ($receiverMapping as $name => $reference) { | ||
$receiverNames[(string) $reference] = $name; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.