Question

I'm not having much luck with background queues at the moment. I'm attempting to get Resque to work. I've installed redis and the Resque gem.

Redis is running. A worker is running (rake resque:work QUEUE=simple). Using the web interface I can see that the worker is running and awaiting a job.

When I run 'rake get_updates', the job is queued but fails. I've tried it both with def self.perform and def perform.

clockwork.rake

task :get_updates => :environment do
    Resque.enqueue(GetUpdates)
end

Class file (app/workers/get_updates.rb)

class GetUpdates
    @queue = :simple

    def perform

        puts "Running GetUpdates"

    end

end

Error Message

undefined method `perform' for GetUpdates:Class
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/bundler/gems/resque-620d354454b8/lib/resque/job_performer.rb:79:in `perform_job'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/bundler/gems/resque-620d354454b8/lib/resque/job_performer.rb:46:in `execute_job'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/bundler/gems/resque-620d354454b8/lib/resque/job_performer.rb:25:in `perform' 
Was it helpful?

Solution

perform method should be class instance method.

class GetUpdates
  @queue = :simple

  def self.perform
    puts "Running GetUpdates"
  end

end

OTHER TIPS

Did you try restarting resque after changing the method to self.perform. Quit the rake resque and start again after changing the method name to self.perform. This should work for sure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top