0

Здравствуйте! Подскажите, пожалуйста, как настроить очереди в laravel? Если несложно краткую инструкцию...

Дело в том, что сейчас очереди выполняются сразу же, без каких либо задержек, а мне нужно выполнение через три/пять минут.

3 ответа 3

1

Очереди для того и созданы что бы выполнятся по очереди и мгновенно если очередь не пустая.

Единственный способ в этом случае, внутри задачи, в самом начале поставить sleep(количество секунд).

Задача выполнится с задержкой и пока она работает, следующая не запустится.

0

Хорошо рассказано про то, как работать с очередями тут. Если из других источников, то вот

0

Отсюда для 5.2: https://laravel.com/docs/5.1/queues#delayed-jobs

you may wish to queue a job that sends a customer a reminder e-mail 15 minutes after sign-up. You may accomplish this using the delay method on your job class, which is provided by the Illuminate\Bus\Queueable trait:

<?php

namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\Request;
use App\Jobs\SendReminderEmail;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * Send a reminder e-mail to a given user.
     *
     * @param  Request  $request
     * @param  int  $id
     * @return Response
     */
    public function sendReminderEmail(Request $request, $id)
    {
        $user = User::findOrFail($id);

        $job = (new SendReminderEmail($user))->delay(60);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.