Skip to content

Commit

Permalink
Send full job back into RedisQueue.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 23, 2017
1 parent fed36bd commit 16e862c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Queue/Jobs/RedisJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function delete()
{
parent::delete();

$this->redis->deleteReserved($this->queue, $this->reserved);
$this->redis->deleteReserved($this->queue, $this);
}

/**
Expand All @@ -95,7 +95,7 @@ public function release($delay = 0)
{
parent::release($delay);

$this->redis->deleteAndRelease($this->queue, $this->reserved, $delay);
$this->redis->deleteAndRelease($this->queue, $this, $delay);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Queue/RedisQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,19 @@ protected function retrieveNextJob($queue)
* Delete a reserved job from the queue.
*
* @param string $queue
* @param string $job
* @param \Illuminate\Queues\Jobs\RedisJob $job
* @return void
*/
public function deleteReserved($queue, $job)
{
$this->getConnection()->zrem($this->getQueue($queue).':reserved', $job);
$this->getConnection()->zrem($this->getQueue($queue).':reserved', $job->getReservedJob());
}

/**
* Delete a reserved job from the reserved queue and release it.
*
* @param string $queue
* @param string $job
* @param \Illuminate\Queues\Jobs\RedisJob $job
* @param int $delay
* @return void
*/
Expand All @@ -234,7 +234,7 @@ public function deleteAndRelease($queue, $job, $delay)

$this->getConnection()->eval(
LuaScripts::release(), 2, $queue.':delayed', $queue.':reserved',
$job, $this->availableAt($delay)
$job->getReservedJob(), $this->availableAt($delay)
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Queue/QueueRedisJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testDeleteRemovesTheJobFromRedis()
{
$job = $this->getJob();
$job->getRedisQueue()->shouldReceive('deleteReserved')->once()
->with('default', json_encode(['job' => 'foo', 'data' => ['data'], 'attempts' => 2]));
->with('default', $job);

$job->delete();
}
Expand All @@ -34,7 +34,7 @@ public function testReleaseProperlyReleasesJobOntoRedis()
{
$job = $this->getJob();
$job->getRedisQueue()->shouldReceive('deleteAndRelease')->once()
->with('default', json_encode(['job' => 'foo', 'data' => ['data'], 'attempts' => 2]), 1);
->with('default', $job, 1);

$job->release(1);
}
Expand Down

0 comments on commit 16e862c

Please sign in to comment.