when retrieving queue name, check for 'queue_name' which is how ActiveJob defines queue names#1713
when retrieving queue name, check for 'queue_name' which is how ActiveJob defines queue names#1713josh-m-sharpe wants to merge 1 commit intoresque:masterfrom
Conversation
|
But either way, Resque should not know anything about Active Job. Why do you think this change is necessary? The Active Job adapter already set the correct queue name to Resque. https://github.com/rails/rails/blob/855c9897eb98ea4d77ec5036d15cdd1764698838/activejob/lib/active_job/queue_adapters/resque_adapter.rb#L33 |
…ob defines queue names
3a4994b to
b47c015
Compare
|
Branch updated to use I needed this to allow resque-scheduler to correctly queue ActiveJobs: https://github.com/resque/resque-scheduler/blob/master/lib/resque/scheduler/server.rb#L149 - that plugin uses I suspect this fix is probably still necessary in this context given that |
|
Yea, I think the issue (which has nothing to do with resque-scheudler) is that |
|
That makes sense. That happen because resque doesn't, and should not, know about Active Job. So Also, we can't determine the queue name for a subclass of That being said, in order to expose the queue for a job we will need to make significant changes to the Resque plugin in Active Job to wrap each job in a class like we do in the Sidekiq adapter. |
This PR is doing: Apologies, but I'm not sure I follow what you are saying here:
|
There was a problem hiding this comment.
@josh-m-sharpe Although I agree with rafaelfranca in principle—that resque shouldn't know about ActiveJob—I think it's a better UX to add some light bindings / support for ActiveJob given that's a very popular pattern.
@rafaelfranca Could you explain further why "we will need to make significant changes to the Resque plugin in Active Job"? I'm not seeing any issues here, but I don't have as much experience with ActiveJob.
| (klass.respond_to?(:queue) and klass.queue) | ||
| klass.instance_variable_get(:@queue) || | ||
| (klass.respond_to?(:queue) && klass.queue) || | ||
| (klass.respond_to?(:queue_name) && klass.new.queue_name) |
There was a problem hiding this comment.
You could add more inline documentation here about what cases these different lines are handling? Even just a link to this PR in code would be helpful.
There was a problem hiding this comment.
@josh-m-sharpe quick reminder here! Would love to tidy up this PR and get it merged.
There was a problem hiding this comment.
Feel free to tidy it up and get it merged!
There was a problem hiding this comment.
Thank you for this, I found it useful. Has it been superseded by another solution or shall I fork/rebase and resubmit?
This fixes an issue when queueing jobs from resque-scheduler's Scheudle page. Without this change, resque is unable to identify the queue to drop the job on.
ActiveJob details:
https://api.rubyonrails.org/classes/ActiveJob/QueueName/ClassMethods.html#method-i-queue_as
https://github.com/rails/rails/blob/157920aead96865e3135f496c09ace607d5620dc/activejob/lib/active_job/queue_name.rb#L41
https://github.com/rails/rails/blob/157920aead96865e3135f496c09ace607d5620dc/activejob/lib/active_job/queue_name.rb#L62