Have you checked your dev tools?
Jan 30, 2021
7
Level 2
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 !
Please or to participate in this conversation.