3

I implemented a laravel queue with the database driver, in an Ubuntu 14.04 server. I execute this code

php /path to app/artisan queue:listen --tries=3 --env=local

It says tries=3. But when I see the jobs table I see jobs with 22 attempts, how is this possible? it should try 3 times and then add it to failed_jobs table.

Also, what does reserved_at means in the jobs table?.

Thank you

Here is the job that, by the way, it works perfectly

<?php

namespace App\Jobs;

use App\Jobs\Job;
use App\Notifiers\Im_Notification;
use App\Notifiers\Notification;
use App\Notifiers\Mail_Notification;
use App\Reservation;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class NotifyPlaceReservationStatus extends Job implements ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

/**
 * Create a new job instance.
 *
 * @return void
 */
protected $notification;
protected $reservation;
protected $info_changed;

public function __construct(Notification $notification,Reservation $reservation)
{
    $this->reservation = $reservation;
    $this->notification = $notification;
}

/**
 * Execute the job.
 *
 * @return void
 */
public function handle()
{
    $this->notification->notifyPlaceReservationStatus($this->reservation);
}

public function failed()
{
    error_log('Job failed');
}
}
2
  • You should show the job it self. The problem might lie there. Commented May 16, 2016 at 23:00
  • Ok, I put it. Thank you Commented May 17, 2016 at 0:53

1 Answer 1

1

When you provide the number of tries in the CLI, Laravel worker is going to apply the tries limit only for those jobs currently in the queue (or in your unexecuted job table if you prefer). In order to make every execution of a job have a try limit, you should put a public $tries attribute in your Job class as stated in the Laravel documentation on Dispatching Jobs (for Laravel 5.4)

public $tries = 3;
protected $notification;
protected $reservation;
protected $info_changed;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.