views:

60

answers:

2

I have been running delayed_job and was hitting some errors, but now I don't know what is sitting in the job queue or what's going on with them....

How can I figure that out so I can debug whether it is able to execute what has been put in the queue?

Here is where I call the job (it is part of a cron task) and the mailer it calls:

  class SomeMailJob < Struct.new(:contact, :contact_email) 
   def perform
     OutboundMailer.deliver_campaign_email(contact,contact_email)
   end
 end

#class OutboundMailer < ActionMailer::Base
class OutboundMailer < Postage::Mailer 

  def campaign_email(contact,email)
    subject    email.subject
    recipients contact.email
    from       'Timothy Fong <[email protected]>'
    sent_on    Date.today

    body       :email => email
  end
+1  A: 

You have to be careful to set Delayed::Job.destroy_failed_jobs = false because by default after 25 tries a job will be deleted. Then you can see which jobs failed (and what time in the failed_at field). There's a rake task to clean them up.

Another queue to look at is Resque, which comes with a little management app to monitor queues. Its introduction is a good read.

Mark Thomas
A: 

You can gain insight into your delayed_job queue through the Delayed::Job model (I think the name of it might have changed in later versions). It's just an ActiveRecord model and you can do all the things you'd do to a normal one. Find all, find ones with failed_at set, find ones with locked_by set (currently being worked).

I find they're much easier to read if you to_yaml them first: y Delayed::Job.all from console.

tfe