Home Ask Login Register

Developers Planet

Your answer is one click away!

John February 2016

why doesn't my delayed job work more than once when being triggered from a rails server?

given the delayed job worker,

class UserCommentsListWorker
  attr_accessor :opts
  def initialize opts = {}
    @opts = opts

  def perform

  def before job
    p 'before hook', job 

  def after job
    p 'after hook', job

  def success job
    p 'success hook', job

  def error job, exception
    p '4', exception

  def failure job
    p '5', job

  def enqueue job
    p '-1', job


When I run Delayed::Job.enqueue UserCommentsListWorker.new(client: client) from a rails console, I can get repeated sequences of print statements and a proper delayed job lifecyle even hooks to print including the feedback from the worker that the job was a success.

Including the same call to run the worker via a standard rails controller endpoint like;

include OctoHelper
include QueryHelper
include ObjHelper
include StructuralHelper

class CommentsController < ApplicationController
  before_filter :authenticate_user!

  def index
    if params['updateCache'] == 'true'
      client = build_octoclient current_user.octo_token
      Delayed::Job.enqueue UserCommentsListWorker.new(client: client)

I'm noticing that the worker will run and created the delayed job, but none of the hooks get called and the worker nevers logs the job as completed.

Notice the screenshot, enter image description here

Jobs 73,75,76 were all triggered via a roundtrip to the above referenced endpoint while job 74 was triggered via the rails console, what is wrong with my setup and/or what am I failing to notice in this process? I will stress that the first time the webserver hits the above controller endpoint, the job queues and runs properly but all subsequent instances where the job shou


John February 2016

The long and the short of the answer to this problem was that if you notice, i was attempting to store a client object in the delayed job notification which was causing problems, so therefore, don't store complex objects in the job, just work with basic data ids 1 or strings foo or booleans true etc. capisce?

Post Status

Asked in February 2016
Viewed 1,729 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life