We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent df5e3a1 commit bd354d8Copy full SHA for bd354d8
src/Jenssegers/Mongodb/Queue/MongoQueue.php
@@ -13,13 +13,20 @@ class MongoQueue extends DatabaseQueue
13
*/
14
protected function getNextAvailableJob($queue)
15
{
16
- $job = parent::getNextAvailableJob($queue);
+ $job = $this->database->table($this->table)
17
+ ->lockForUpdate()
18
+ ->where('queue', $this->getQueue($queue))
19
+ ->where('reserved', 0)
20
+ ->where('available_at', '<=', $this->getTime())
21
+ ->orderBy('id', 'asc')
22
+ ->first();
23
24
if ($job) {
25
+ $job = (object) $job;
26
$job->id = $job->_id;
27
}
28
- return $job;
29
+ return $job ?: null;
30
31
32
/**
0 commit comments