title: Jobs in the queue(pub-sub) distributed systems with dependencies?
body: <p>How to approach a problem when there are jobs put in the queue(pub-sub) <em>distributed systems</em>, and they have a dependency between them.</p>
  
  <blockquote>
    <p>For e.g. current state of the queue:</p>
  
  <pre><code>j3 -&gt; j2 -&gt; j1
  rear      front
  </code></pre>
    
    <p>j3 depends on the completion of j1.</p>
  </blockquote>
  
  <p>The queue processor is consuming these jobs and started processing it in a distributed environment.</p>
  
  <p>Based on some dependency resolution mechanism, dependency between <code>j1</code> and <code>j3</code> was found out.</p>
  
  <p>Now, what I don't know is, the best way to deal with situation:</p>
  
  <ul>
  <li>should I put <code>j3</code> back in the queue, and again pick it up at the
  later stage so that <code>j1</code> would have completed by that time?</li>
  <li>should I have some other mechanism - database to check if all the
  <code>j3</code> dependencies have met and then process <code>j3</code>?</li>
  </ul>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks!</p>