-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Bulk dispatching jobs onto the DatabaseQueue does not trigger jobs #52689
Comments
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
Hey! 👋 You’re right—when pushing an array of jobs to the database queue with the bulk method, the JobQueueing and JobQueued events aren’t triggered. This is different from the behavior on Redis or SQS queues, which can definitely cause inconsistencies. One option is to manually trigger these events in your code before and after the bulk dispatch. Here’s a quick example: use Illuminate\Support\Facades\Event; $jobs = [ /* your array of jobs */ ]; foreach ($jobs as $job) { Bus::batch($jobs)->onConnection('database')->dispatch(); foreach ($jobs as $job) { This will manually raise the JobQueueing and JobQueued events, ensuring consistency across different queue drivers. Hope this helps! 😊 |
I have encountered the same issue with the Issue AnalysisIt seems that the Proposed SolutionTo ensure consistency across queue connections, I suggest modifying the This can be done by:
Code SuggestionHere’s an example modification in foreach ($jobs as $job) {
$this->raiseJobQueueingEvent($job);
$this->insertIntoDatabase($job);
$this->raiseJobQueuedEvent($job);
} |
I'm in a project with v11.44.0. I'm getting this error when using
When attempting to use any of the additional chained methods, it comes up with one of two possible errors:
Which leads me to this documentation below it:
I haven't tested this yet, but the implication seems to be that it is better to pass in some kind of serializable, invokable object that can be reconstructed from the batch job storage mechanism rather than a callback. IMO that also warrants a documentation update at least. |
Laravel Version
11.20.0
PHP Version
8.3.9
Database Driver & Version
No response
Description
When pushing an array of jobs onto the database queue using the bulk method the JobQueueing and JobQueued events are not triggered.
In contrast, when pushing an array of jobs onto the redis queue or the SQS queue using the bulk method, these event are triggered (as they should be imho).
I think that @RuslanMelnychenko also described symptoms of this bug in #52380.
I see two potential solutions:
Steps To Reproduce
Add a listener for JobQueueing and dispatch jobs onto different queues:
The listener will not be invoked when using the database connection, while it will be invoked for the redis connection.
The text was updated successfully, but these errors were encountered: