Jonathan Chan Jonathan Chan - 2 months ago 12
Ruby Question

Rails 5 - Resque not processing enqueued job

I'm trying to do enqueue a simple job using

Resque
1.26.0 (and
Redis-rb
3.3.1). The job doesn't seem to be processing the
perform
function because
resque-web
is processing each job and shows 0 failures. The jobs also are being processed instantly.

The jobs are enqueued from a controller action with

Resque.enqueue(TestJob, url)


The job itself looks like

class TestJob < ApplicationJob
@queue = :tags_queue
Logger.new("log/resque_worker_QUEUE.log").fatal("thing")

def self.perform(url)
Logger.new("log/resque_worker_QUEUE.log").fatal("other thing")
logger.fatal("more errors please")

myDivideByZeroVar= 1/0
raise "error"
Logger.new("log/resque_worker_QUEUE.log").fatal("other thing")
logger.fatal("more errors please")
end
end


A rake task is also set up:

require 'resque/tasks'
task "resque:setup" => :environment


The
redis-server
is running.

The worker is started with
rake resque:work QUEUE=*
. Using verbose logging doesn't show anything useful.

The log file only shows the first fatal error string "thing". None of the other errors are logged that are inside
perform
.

What am I doing wrong here?

Answer

Solved this. The job needed to be called using ActiveJob instead of using Resque.enqueue. TestJob.perform_later(url) worked just fine.

Comments