drfeelngood / resque-batched-job

Resque plugin that understands individual jobs can belong to something bigger than themselves
https://rubygems.org/gems/resque-batched-job
MIT License
49 stars 23 forks source link

resque-batched-job + resque + activejob? #28

Open sepastian opened 9 years ago

sepastian commented 9 years ago

How does one use resque-batched-job with activejob? My self.after_batch_finished hook never gets invoked.

require 'resque/batched_job'

class MyJob < ActiveJob::Base
  extend Resque::Plugins::BatchedJob
  def perform(bid, args)
    # Perform job.
  end
  def self.after_batch_finished(bid, *args)
    # Never reaching this.
  end
end

What am I doing wrong?

sepastian commented 9 years ago

"Solved."

Don't use Resque 2.0, use 1-x-stable. Version 2 It is not ready yet. Unfortunately, figuring that out took way too long, because the README is not clear about it.

Don't use ActiveJob. Without further investigating this, callbacks/hooks did not get called when wrapping ActiveJob aroud Resque. Using Resque directly enables callbacks.

Hope this is useful for anyone. I'm leaving this open, just in case there is a better solution...

(For completeness, I'm now using Rails 4.2 and resque 1-x-stable.)

travisdmathis commented 9 years ago

before I was using enqueue_batched_job, I can't seem to find anything on syntax for enqueueing a batched job w/ activejob.. anything I need to change or should I just leave them the same?

drfeelngood commented 9 years ago

It appears ActiveJob is an abstraction layer for jobs and the actual backend job processing framework. resque-batched-job is a hackery that implements #enqueue_batched_job which is not and probably will never be included in the ActiveJob smoke screen. I suggest keep rocking the #enqueue_batched_job method or monkey patch ActiveJob locally.