1

I've implemented Ahoy for tracking events inside my application and I want to move the processing into a background job.

My setup works fine when I call perform_now (the job gets processed), but changing to perform_later doesn't work. From the logs, it seems the job doesn't even get enqueued.

config/initializers/ahoy.rb

class Ahoy::Store < Ahoy::BaseStore
  def track_visit(data)
    AhoyTrackVisitJob.perform_later(@options, data)
  end

  def track_event(data)
    AhoyTrackEventJob.perform_later(@options, data)
  end
end

app/jobs/ahoy_track_event_job.rb

class AhoyTrackEventJob < ApplicationJob
  queue_as :default

  def perform(options, data)
    Ahoy::DatabaseStore.new(options).track_event(data)
  end
end

I've tried with both Sidekiq and SuckerPunch:

development.rb
config.active_job.queue_adapter = :sidekiq
Daniel Friis
  • 444
  • 3
  • 23
  • Hope you don't mind asking but did you make sure to start a Sidekiq process locally? – Holger Frohloff Mar 23 '18 at 21:35
  • Yes. 100%. I have other jobs performing just fine. When I add `binding.pry` and run `AhoyTrackEventJob.perform_later(@options, data)` manually I get an exception `ActiveJob::SerializationError - Unsupported argument type`. The exception doesn't appear if I don't call it manually in console. – Daniel Friis Mar 25 '18 at 15:11
  • Did you check your arguments for their ability to be serialized? Are they simple types (isn't clear from your code samples)? If the other jobs serialize well and are executed it might indicate that something is off with this specific job and not your setup in general. – Holger Frohloff Mar 26 '18 at 08:20

0 Answers0