mardi 24 novembre 2020

Laravel Delayed queued jobs disappearing randomly

I'm facing a very strange issue for a long time now. I am working in Laravel 5.3. The problem is with delayed queues.

i.e. for my customer's I have something to do via queue jobs.

But sometimes my jobs disappears randomly. I can't see them in logs, failed_jobs table or anywhere. Even if my action / data is the same, It will work first time. 2nd time may be done't.

I had tried putting some logs. They gave me no issue. And getting passed successfully before / after where I'm placing queue job in my code.

I've tried this on Laravel 8 also. But the issue is same.

Before my QUEUE_CONNECTION was SYNC But i've also tested with following. But the result is same

QUEUE_DRIVER=redis

QUEUE_CONNECTION=redis

QUEUE_DRIVER=database

QUEUE_CONNECTION=database

Current code.

queue.php

return [

/*
|--------------------------------------------------------------------------
| Default Queue Driver
|--------------------------------------------------------------------------
|
| The Laravel queue API supports a variety of back-ends via an unified
| API, giving you convenient access to each back-end using the same
| syntax for each one. Here you may set the default queue driver.
|
| Supported: "null", "sync", "database", "beanstalkd", "sqs", "redis"
|
*/

'default' => env('QUEUE_DRIVER', 'redis'),
'failed' => [
    'database' => env('DB_CONNECTION', 'mysql'),
    'table' => 'failed_jobs',
],

.env

QUEUE_DRIVER=redis
QUEUE_CONNECTION=redis

jobFile.php

<?php

 namespace App\Jobs;

 use Illuminate\Bus\Queueable;
 use Illuminate\Queue\SerializesModels;
 use Illuminate\Queue\InteractsWithQueue;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Support\Facades\Log;

 class jobFile implements ShouldQueue
 {
     use InteractsWithQueue, Queueable, SerializesModels;

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

/**
 * Execute the job.
 *
 * @return void
 */
public function handle()
{

And this is how i am placing jobs

   $this->dispatch((new jobFile($id))->onQueue('high')
            ->delay(Carbon::now()->addMinutes(1)))
   );

   Also tried with dispatch().

Can anyone please let me know what can i do for fixing this problem?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/39jxWCS
via IFTTT

Aucun commentaire:

Enregistrer un commentaire