mercredi 12 décembre 2018

Laravel Queue - Pause between jobs

I want to create a queue (FIFO SQS) that only runs jobs every X sec. So if suddenly 50 jobs are submitted, the end up in the queue. The queue listener then pulls a job, does something and waits X sec. After that, the next job is pulled. Another X sec pause. Etc etc

For the queue listener, the sleep option option only determines how long the worker will "sleep" if there are no new jobs available. So it will only sleep if there is nothing in the queue.

Or should I just put in a pause(x) in my PHP code?

<?php

namespace App\Jobs;

use App\City;

class RetrieveStations extends Job
{
protected $cities;

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

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



    // code here
      doSomething()
      sleep(X);


}
}



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

Aucun commentaire:

Enregistrer un commentaire