I want all the enqueue calls to default to a certain queue unless specified otherwise so it's DRY and easier to maintain. In order to specify a queue, the documentation said to define a variable @queue = X within the class. So, I tried doing the following and it didn't work, any ideas?
class ResqueJob
class << self; attr_accessor :queue end
@queue = :app
end
class ChildJob < ResqueJob
def self.perform
end
end
Resque.enqueue(ChildJob)
Resque::NoQueueError: Jobs must be placed onto a queue.
from /Library/Ruby/Gems/1.8/gems/resque-1.10.0/lib/resque/job.rb:44:in `create'
from /Library/Ruby/Gems/1.8/gems/resque-1.10.0/lib/resque.rb:206:in `enqueue'
from (irb):5
Open up http://localhost:3000/resque in a browser to check out the web running jobs and schedules. If you are using Resque-scheduler then it will add more options for you in the resque-web UI. Those options allows you to view queues and manually start queuing.
Active Job is a framework for declaring jobs and making them run on a variety of queueing backends. These jobs can be everything from regularly scheduled clean-ups, to billing charges, to mailings. Anything that can be chopped up into small units of work and run in parallel, really.
Resque-scheduler is an extension to Resque that adds support for queueing items in the future. Job scheduling is supported in two different ways: Recurring (scheduled) and Delayed. Scheduled jobs are like cron jobs, recurring on a regular basis.
Enqueue jobs The different enqueuing options are the following: wait : With this, the job is enqueued after the mentioned time period. wait_until : With this, the job is enqueued after that the specified time has elapsed. queue : With this, the job is added to the specified queue.
In ruby, class variables are not inherited. That is why Resque can't find your @queue variable.
You should instead define self.queue
in your parent class. Resque first checks for the presence of @queue, but looks secondarily for a queue
class method:
class ResqueJob
def self.queue; :app; end
end
class ChildJob < ResqueJob
def self.perform; ...; end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With