I'm creating a job, pushing it on to a custom queue, and trying to use the Redis driver to then handle the job when it hits the queue, without success:
class MyController extends Controller {
public function method() {
$job = (new UpdateLiveThreadJob())->onQueue('live');
$this->dispatch($job);
}
}
Here is my queue config:
'default' => env('QUEUE_DRIVER'),
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'expire' => 60,
],
Here is my .env
file:
# Drivers (Queues & Broadcasts)
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=redis
BROADCAST_DRIVER=redis
Here's my job:
class UpdateLiveThreadJob extends Job implements SelfHandling, ShouldQueue
{
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
// Rerender content
$templatedOutput = view('templates.livethreadcontents')->with([
'updates' => collect(Redis::lrange('live:updates', 0, -1))->reverse()->map(function($update) {
return json_decode($update);
})
])->render();
// Connect to external service
// Update Thread
}
}
Indeed, I can change the handle
method to do nothing to ensure it's nothing in the job that's actually causing it to fail, and it still doesn't process:
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
print_r('test');
}
Using Redis, I can see it's pushed onto the queue:
> lrange queues:live 0 -1
> // json encoded job present
> llen queues:live
> // shows there is a job in the queue
Yet, it never actually fires, to my knowledge. Watching php artisan queue:listen
shows nothing (only unrelated event broadcasts). What's going on here?