i am using postgresql as db, in .env i have set QUEUE_CONNECTION = database
I download from url, for example, a picture and transfer it to the queue for uploading in storage laravel
In web.php, I registered a route to the queue
Route::get('/job', function () {
App\Jobs\FileAdd::dispatch("https://www.example.com/example.jpg")->delay(now()->addMinute(25));
});
In job, I wrote the following:
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;
class FileAdd implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $File;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($File)
{
$this->File = $File;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
info($data = $this->File);
$pos = strripos($data, '/');
$link = substr($data, 0 , $pos+1);
$filename = substr($data, $pos+1);
$expansion = substr($filename, -4);
$tempImageTwink = tempnam('..\storage\app\public', $filename);
$tempImage = substr($tempImageTwink, 0, -4) . $expansion;
copy($link . '/' . $filename, $tempImage);
Storage::delete('exa3BBD.tmp');
response()->download($tempImage, $filename);
unlink(($tempImageTwink ));
}
}
in the database I have two tables jobs, failed_jobs, for writing queues, but they are executed immediately without delay, what could be the problem?