title: Deleting Running Jobs from Beanstalkd Queue in laravel
body: <p>Here is the scenario, I'm using Beanstalkd queue to send an email to a huge list of emails (50000+), each email has to have some unique content so the fired job loops over all the addresses, generates the content and sends the mail.</p>
  
  <p>Sometimes the user may want to cancel the operation in the middle of sending, so for example while the job is running and after the mail was sent to say 20000 addresses, the user clicks on "Stop" which should "delete" the job.</p>
  
  <p>what I have done so far is that I managed to get the running job instance, Queue::Push returns the job ID, so I save this ID saved in DB, and when I want to stop the job this is what I tried to do </p>
  
  <pre><code>$phean= Queue::getPheanstalk();
  
  $res = $phean-&gt;peek($Job_ID); // returns a Pheanstalk_Job
  $job = new \Illuminate\Queue\Jobs\BeanstalkdJob(app() , $phean, $res , 'default') ;
  
  $res = $job-&gt;delete() // returns NOT_FOUND ??
  $data = $job-&gt;getRawBody() // returns correct data, so I'm sure this is the right job instance
  </code></pre>
  
  <p>so why do I get NOT_FOUND, although when I use 
      supervisorctl tail -f queuename 
  I can see that the job is still running and outputting content </p>
  
  <p>Any help ? If there is a better approach than trying to get the job and delete it this way I'm open to suggestions, I thought about saving the job ID in database (ID , status), and when I want to delete it I alter the ID status, and In the loop that is running within the job it checks every time, or maybe every 10 times, and if the status is equal to 1 for example then $job->delete(), but this will be so slow as it will hit the db in every loop.</p>