Reputation: 2187
I have a synchronous process that takes about 7 hours to finish and I'm trying to convert it into jobs to speed it up. The problem is I need to make sure all jobs in step1 are finished before I dispatch step2 jobs.
I'm using Beanstalkd as my queue driver in Laravel. One possible solution that comes to my mind is running a while loop constantly checking if the queue is empty but that doesn't guarantee the last few jobs being done.
Here is what I'm trying to do in a nutshell:
//Step 1
ModelA::chunk(1000,function($rows){
foreach($rows as $row){
Dispatch(new JobA($row);
}
}
//I Need To Make Sure STEP1 is Done Before I Proceed
//Step 2
ModelB::chunk(1000,function($rows){
foreach($rows as $row){
Dispatch(new JobB($row);
}
}
I'm also open to a different way of doing this.
Upvotes: 2
Views: 4246
Reputation: 23
Probably Laravel 8 Queue Batch may work. If not, try this package https://github.com/spatie/async
Upvotes: 1