title: Laravel Queue - Pause between jobs
body: <p>I want to create a queue (AMAZON 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</p>
  
  <p>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.</p>
  
  <p>Or should I just put in a pause(x) in my PHP code?</p>
  
  <p>[edit] I just tested the sleep method with a FIFO and standard AWS SQS queue and this messes up the whole queue. Suddenly jobs are (sucesssfully) resubmitted 3 times after which the go into failed state. Moreover, the delay that is given in my code (3-4 min) was ignored, instead a one minute was taken</p>
  
  <pre><code>&lt;?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-&gt;cities = $cities;
  }
  
  /**
   * Execute the job.
   *
   * @return void
   */
  public function handle()
  {
  
  
  
      // code here
        doSomething()
        sleep(X);
  
  
  }
  }
  </code></pre>