I wish I could decide on which queue to go to work. This is because if the job is scheduled by the server (cronjob) it must be run on a slow queue, if instead it is run by the user it will go on a fast queue. How can I run this in Resque?
Controller
MyJob.perform_later(id, :fast)
Rake task
MyJob.perform_later(id, :slow)
Job
class MyJob < ApplicationJob
queue_as :default #<-- This has to be dynamic
def perform(item_id, queue_name)
....
end
I see you are using ActiveJob
, you can set the queue by using set
method:
Controller
MyJob.set(queue: :fast).perform_later(id)
Rake task
MyJob.set(queue: :slow).perform_later(id)
set
method allows you to set more thing than just queue, you can also set eg priority or when should job be performed. See the documentation https://api.rubyonrails.org/v5.2.3/classes/ActiveJob/Core/ClassMethods.html#method-i-set
Note: I presume, you already have slow and fast Resque queues in place and running and only want to use them
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