yii2-queue
yii2-queue copied to clipboard
Check status by class name
From docs - to see status need pass job id
if (!Yii::$app->queue->isDone($id))
echo 'working...'
What about check status by class name?
For example Yii::$app->queue->isAnyWorking(testJob::class)
which mean- is any not done job for class TestJob?
What is the use case for it?
For example-I need add many users to system
I create 10 queue jobs, then from frontend I check
if (Yii::$app->queue->isAnyWorking(testJob::class)) then echo 'add in progress'
Now I need save all ids and then in loop check
foreach ($idList as $id) {
if (Yii::$app->queue->isWaiting($id) || Yii::$app->queue->isReserved($id)) {
echo 'working...'
break;
}
}
OK. That may be useful.
Any idea how do you want to implement it? Most of backends does not allow to filter by anything except job ID, so the only way to do this would be to log IDs of jobs and query each of them separately. Exactly in the same way as you're doing it now.
Yes. With the current info stored it is exactly how @rob006 suggests it.