title: Synchronize jobs Laravel
body: <p>I have 4 methods: A, B1, B2, B3 and want to encapsulate their execution in separate jobs. A generates result that B uses so A must be finished before starting B, and if A fails don't start B. Also for performance reasons I don't want B1, B2, B3 to run concurrently, but sequential, start B2 when B1 is finished, but they don't share results so if some B fails, start other normally. I don't want any retry on fail, just one attempt for each. So execution order is A->B1->B2->B3.</p>
  
  <p>In docs there is not much about synchronizing mechanisms, so it's not obvious how to implement this. I found Queue::after handler, which as I understand fires on every job end, how do you filter which job? By class <code>if(is_a($event-&gt;job , 'JobAClass'))...</code>?</p>
  
  <p><a href="https://laravel.com/docs/5.3/queues#job-events" rel="nofollow">https://laravel.com/docs/5.3/queues#job-events</a></p>
  
  <pre><code>    Queue::after(function (JobProcessed $event) {
          // $event-&gt;connectionName
          // $event-&gt;job
          // $event-&gt;job-&gt;payload()
      });
  </code></pre>