mallaury's avatar

Queue : job table filled but nothing append

Hello,

I have been struggling for 2 hours with a laravel jobs problem. I am trying to convert documents to pdf when I upload them.

I do not have any errors, but documents are not converted. The "jobs" table is filled and the "jobs_failed" table is empty.

I have nothing when I run the command "php artisan queue:work"

Here is my configuration (I am using Laravel 6) :

.env :

QUEUE_CONNECTION=database // I also tried with queue_driver=database

When I set it to "sync", the document is convert but it does not run in a queue

The job :

<?php

namespace App\Jobs;

use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Http\Controllers\Document\ILovePDFController;

/**
 * Convert office document into pdf
 */
class ConvertDocument implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $path;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($path)
    {
        $this->path = $path;
    }

    /**
     * Execute the job.
     * Convert a file in pdf
     *
     * @return void
     */
    public function handle()
    {
        ILovePDFController::convert_document($this->path);
    }

    /**
     * The job failed to process.
     *
     * @param  Exception  $exception
     * @return void
     */
    public function failed($exception)
	{
		// It never does there
	}
}

Where I call the job

<?php
namespace App\Http\Controllers\Document;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class DocumentController extends Controller {

	 public function store(Request $request, Department $department, Lesson $lesson, int $year) {
		// TODO
		if ($extension != 'pdf') {
            \App\Jobs\ConvertDocument::dispatch($path);
        }
		// TODO
	}

}

Then I run :

php artisan queue:work

And nothing appear when I upload a document... As I said, this code works perfectly because when I disable queue jobs it converts properly.

Thanks for your help !

0 likes
7 replies
mallaury's avatar

I have logged everything I can. But I do not know how to debug laravel queue...

It works properly in "sync" mode but it does not work in "database" mode, so I guess I just misconfigured something

ep!sode's avatar

Maybe try:

config:clear

config:cache

cache:clear

Then restart the worker.

mallaury's avatar

I already tried it. I tried again but it does not change anything... :/

ajithlal's avatar

Stop the queue worker. Close and reopen the terminal and try running queue:work or queue:listen

Snapey's avatar

don't run php artisan config:cache unless this is a production site

check your config with tinker.

>>> config('queue')
mallaury's avatar

:o

I think I just found the problem. My server was in maintenance mode...

I disabled it, now it works

But is this a normal behaviour ?

Please or to participate in this conversation.