Hello guys,
Do you know how can I handle a failed jobs ?
I need to dispatch an event when a specific job failed (for some reason), but the failed() method is never called even if the job is fail.
class AnnotationGeneration implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
public string $locale;
/**
* The number of times the job may be attempted.
*
* @var int
*/
public int $tries = 1;
/**
* Create a new job instance.
*
*/
public function __construct()
{
//
}
/**
* Execute the job.
*/
public function handle(): void
{
throw new Exception("An exception occur...");
}
/**
* Handle a job failure.
*/
public function failed(?Throwable $exception): void
{
logger("failed"); // nothing in logs??
}
}
2024-06-27 18:03:20 App\Jobs\Copilot\AnnotationGeneration .......... RUNNING
2024-06-27 18:03:20App\Jobs\Copilot\AnnotationGeneration ..... 16.31ms FAIL