Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Messenger] support for multiple bindings on the same queue#37722
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
dd55e54
be9e781
c2b77ce
32de160
254ff41
76426b4
52a834b
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -131,6 +131,9 @@ public function __construct(array $connectionOptions, array $exchangeOptions, ar | ||
* * queues[name]: An array of queues, keyed by the name | ||
* * binding_keys: The binding keys (if any) to bind to this queue | ||
* * binding_arguments: Arguments to be used while binding the queue. | ||
* * bindings[name]: An array of bindings for this queue, keyed by the name | ||
* * key: The binding key (if any) to bind to this queue | ||
* * arguments: An array of arguments to be used while binding the queue. | ||
* * flags: Queue flags (Default: AMQP_DURABLE) | ||
* * arguments: Extra arguments | ||
* * exchange: | ||
@@ -443,6 +446,12 @@ private function setupExchangeAndQueues(): void | ||
foreach ($this->queuesOptions as $queueName => $queueConfig) { | ||
$this->queue($queueName)->declareQueue(); | ||
foreach ($queueConfig['bindings'] ?? [] as $binding) { | ||
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. In the example in the PR description, you show using an array key under Author 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. I am not sure there is or should be a correct usage. The original intent was that these bindings could have a developer/human friendly name. I have found that using these names for the bindings is useful when we have more than a dozen bindings. In my projects, all of these bindings would ideally have a name. I do not think I would want to force another developer to do this generally though. I'm okay with any suggestions here though. | ||
$this->queue($queueName)->bind($this->exchangeOptions['name'], $binding['key'] ?? null, $binding['arguments'] ?? []); | ||
} | ||
if (isset($queueConfig['bindings']) && empty($queueConfig['binding_keys'])) { | ||
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. I think this isn't needed? Because if 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. The '?? [null]' in the next line will ensure that bind is called at least once with a null $bindingKey if 'binding_keys' is empty. This would have the effect of binding all messages from the exchange to the queue. | ||
continue; | ||
} | ||
foreach ($queueConfig['binding_keys'] ?? [null] as $bindingKey) { | ||
$this->queue($queueName)->bind($this->exchangeOptions['name'], $bindingKey, $queueConfig['binding_arguments'] ?? []); | ||
} | ||