[7.x] Allow setting the event handler queue via a getQueue() method #32770
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using queued event listeners, it is possible to set the queue the resulting job should be executed on using the
$queue
attribute. This attribute is then adopted by the dispatcher.However, it is not possible to set the queue name from the config, the environment or otherwise programatically, because the listener instance is created without invoking the constructor in
Dispatcher::createListenerAndJob()
. Thus, trying to set the queue name in the constructor or anywhere else in the Listener has no effect.This pull request proposes a non-breaking change to the Dispatcher class that allows a user to set the queue name by defining a
getQueue()
method within the Listener, as it is already done withretryAfter
andretryUntil
methods.If no getQueue method is defined, the code falls back to use the
$queue
attribute or null, as it was before.The benefit of this change is to provide developers with a flexible way to influence the target queues instead of having to hard code them.