[7.x] Allow setting the event handler queue via a getQueue() method#32770
Merged
Conversation
Member
public function __construct()
{
$this->queue = 'whatever-you-want';
} |
Contributor
Author
Sure, as I described above, that was my first attempt, but it doesn't work because the listener is instantiated using Please check out a quick project I hacked together at https://github.com/lupinitylabs/queuename in the hopes of making myself clearer. Please note: the same issue exists with setting the |
Contributor
Author
|
@taylorotwell Any chance to have this re-opened? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
$queueattribute. 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 withretryAfterandretryUntilmethods.If no getQueue method is defined, the code falls back to use the
$queueattribute 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.