keyboard_return  چسبون مقالات آموزشی Releasing all Failed Jobs queue in laravel without ssh
  1. Releasing all Failed Jobs queue in laravel without ssh

To generate the new command in laravel, run php artisan make:command QueueRetryAll. After generating the command, be sure to add \App\Console\Commands\QueueRetryAll::class to the $commands array in the App\Console\Kernel.

laravel queue

 

And replace all of the code in QueueRetryAll.php file with :

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

use Illuminate\Support\Arr;

class QueueRetryAll extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'queue:retry-all';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'retry all failed jobs';

    /**
     * Create a new command instance.
     *
     * @return void
     */


    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
            $ids = Arr::pluck($this->laravel['queue.failer']->all(), 'id');
        foreach ($ids as $id) {
            $this->retryJob($id);
        }
    }

    protected function retryJob($id)
    {
        $failed = $this->laravel['queue.failer']->find($id);

        if (! is_null($failed)) {
            $failed = (object) $failed;

            $failed->payload = $this->resetAttempts($failed->payload);

            $this->laravel['queue']->connection($failed->connection)
                ->pushRaw($failed->payload, $failed->queue);

            $this->laravel['queue.failer']->forget($failed->id);

            $this->info("The failed job [{$id}] has been pushed back onto the queue!");
        } else {
            $this->error("No failed job matches the given ID [{$id}].");
        }
    }

    protected function resetAttempts($payload)
    {
        $payload = json_decode($payload, true);

        if (isset($payload['attempts'])) {
            $payload['attempts'] = 1;
        }

        return json_encode($payload);
    }

}

Now in controller file :

public function QueueRetryAll()
{
Artisan::call('queue:retry-all');
}

Chasboon.ir always is  up to date.

 

 

Releasing all Failed Jobs queue in laravel without ssh - 4.2 از 5 بر اساس 150 رای

امتیاز کاربران

Releasing all Failed Jobs queue in laravel without ssh
دیدگاه‌ها

دیدگاهی وجود ندارد

2024 © Copyright کليه حقوق مادی و معنوی براي چسبون محفوظ است و هرگونه کپی برداری پیگرد قانونی دارد.