New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scheduled jobs set by resque-scheduler are not working with ActiveJob in Rails 4.2 #16933
Comments
What version of Resque are you using ? |
I am using rescue 1.25.2 and resque-scheduler 3.0.0 |
We haven't thought at recurring jobs so far and we don't support this as none of the adapters support this without an external gem. However this is a very nice feature but I don't think we can make it in time for 4.2. Also I'm not sure it will suitable to be included in rails On Tue, Sep 16, 2014 at 10:13 PM, Luis Madrigal notifications@github.com
|
As we are not currently supporting recurring jobs with ActiveJob we're going to close this. If it's possible to support recurring jobs I'm seeing this as a separate gem or in rails 5. Feature requests and talks around them are usually talked in the mailing list (https://groups.google.com/forum/#!forum/rubyonrails-core). |
As a workaround, I'm queing Resque schedules (with no args) to an ActiveJob like this: check_goals:
queue: "goals"
every: "5m"
class: "ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper"
args:
-
job_class: CheckGoalJob
job_id: #{SecureRandom.uuid}
queue_name: goals
arguments:
-
description: "Checks all checkable goals to see if they're achieved" |
@JustinAiken that's nice but as |
I just used a slight variation on @JustinAiken's workaround successfully. I might rewrite all my jobs to use Resque directly, for the time being. It would be nice if ActiveJob supported -- or at least played nice with -- some of the popular job schedulers available. |
@whitehat101 it turned out to be easier for me to simply write to Resque directly for now. @JustinAiken's solution gets the job done, but requires more than a little boilerplate which (in my simple use case) seemed excessive. |
@cmtonkinson When you say "write to Resque directly", how are you doing that? |
Sorry, that's not really clear, is it? What I meant was that in my (very limited use-case) I simply chose not to use |
After much frustration, I ended up going with the wrapper suggested by @JustinAiken. I wrote the following:
Which allows you to keep the regular Resque schedule format and do the following in your
Seems to work for me, but lmk if I'm missing something. |
@ryanwjackson - I liked your idea so much I'm turning it into a gem: https://github.com/JustinAiken/active_scheduler |
This gets the jobs scheduling, but we're using internal Rails classes and according to rails/rails#16933 we should migrate to our custom wrapper job class
Bump? |
Using rails 5.1.3 lib/tasks/rescue.rake
config/redis.yml
config/initializers/resque.rb
app/jobs/execute_active_job.rb
app/jobs/test_job.rb
config/resque_schedule.yml
|
…ike recurring tasks (rails/rails#16933)
I've managed to force scheduler to schedule jobs through ActiveJob using extension support approach. |
Since I stumbled upon this issue. There are now gems that do scheduling using rufus_scheduler (same thing resque-schedule uses) on top of active job. However if like us you have to fit a square peg into round hole (eg. new app into old deploy scripts / monitoring systems), and want to continue using resque-schedule. Then the easiest workaround I've found is: Part 1:
Resque / Schedule initializer:
|
I am using resque, and I am attempting to use resque-scheduler to schedule jobs. I have a schedule that get loaded and the scheduler runs, and even looks like it is running the jobs but it doesn't do anything.
I can enqueue jobs like this and they get processed.
and I get this output in the worker log
But when I try to schedule a job, it looks like the are getting enqueue but they well not doing anything.
Here is the schedule.yml
Here is the output from the scheduled job.
After reading this http://dev.mikamai.com/post/96343027199/rails-4-2-new-gems-active-job-and-global-id
I am suspecting it has something to do with ActiveJob and GlobalId.
Take a look at the difference enqueued
vs scheduled
The jobs themselves were generated via
They look like this:
After, writing most of this, I've have removed 'require "active_job/railtie" ' and rewritten the jobs in the resque way and now they work as expected. So I think that the problem is with active_job and the way that scheduled jobs get queued.
The text was updated successfully, but these errors were encountered: