Questions tagged [rails-activejob]

A Ruby On Rails framework for declaring jobs and performing or enqueuing them.

Active Job is a framework for declaring jobs and making them run on a variety of queueing back-ends. These jobs can be everything from regularly scheduled clean-ups, to billing charges, to mailings. Anything that can be chopped up into small units of work and run in parallel, really.

Active Job is part of Ruby On Rails: https://github.com/rails/rails/tree/master/activejob/ and extends Action Mailer by adding deliver_later method.

The default queue adapter is inline, which does not support enqueuing.

468 questions
90
votes
14 answers

How to test ActionMailer deliver_later with rspec

trying to upgrade to Rails 4.2, using delayed_job_active_record. I've not set the delayed_job backend for test environment as thought that way jobs would execute straight away. I'm trying to test the new 'deliver_later' method with RSpec, but I'm…
bobomoreno
  • 2,848
  • 5
  • 23
  • 42
52
votes
4 answers

Sidekiq Rails 4.2 Use Active Job or Worker? What's the difference

This is my first processing jobs asynchronously I am implementing Sidekiq for background processing in my app. I will use it for reminder emails and in-app notifications. I am confused as to whether I should use Active Job to create a job that…
45
votes
4 answers

How do I schedule recurring jobs in Active Job (Rails 4.2)?

I found this Schedule one-time jobs in Rails but this only shows how schedule one-time. I am interested in scheduling a recurring job. Delayed_job has this self.delay(:run_at => 1.minute.from_now) How do I do something like that in Rails…
luis.madrigal
  • 1,366
  • 1
  • 15
  • 31
43
votes
9 answers

How to check what is queued in ActiveJob using Rspec

I'm working on a reset_password method in a Rails API app. When this endpoint is hit, an ActiveJob is queued that will fire off a request to Mandrill (our transactional email client). I'm currently trying to write the tests to ensure that that the…
mylescc
  • 5,720
  • 3
  • 17
  • 23
36
votes
6 answers

Disable automatic retry with ActiveJob, used with Sidekiq

Is there a way to disable automatic retry with ActiveJob and Sidekiq ? I know that with Sidekiq only, we just have to put sidekiq_options :retry => false as mentioned here : https://github.com/mperham/sidekiq/wiki/Error-Handling#configuration but…
Jules Ivanic
  • 1,579
  • 2
  • 15
  • 28
29
votes
2 answers

Difference between Action Job/Mailer's `deliver_now` and `deliver_later`

The common pattern for interfacing with ActiveJob in Rails is to set up a Job with a perform() method that gets called asynchronously via perform_now or perform_later In the special case of Mailers, you can directly call deliver_now or deliver_later…
user2490003
  • 10,706
  • 17
  • 79
  • 155
27
votes
4 answers

Execute pending job with ActiveJob in rspec

I have this code to test ActiveJob and ActionMailer with Rspec I don't know how really execute all enqueued job describe 'whatever' do include ActiveJob::TestHelper after do clear_enqueued_jobs end it 'should email' do …
Olivier
  • 493
  • 2
  • 6
  • 16
22
votes
6 answers

How to set retry count for Sidekiq with ActiveJob?

From the Rails API, I found ActiveJob can retry_job interval: my_job_instance.enqueue my_job_instance.enqueue wait: 5.minutes my_job_instance.enqueue queue: :important my_job_instance.enqueue wait_until:…
scho
  • 3,275
  • 6
  • 19
  • 30
19
votes
5 answers

How to properly test ActiveJob's retry_on method with rspec?

I have been attempting to test this method for the past few days with no luck. Another thing I'd like to be able to do is rescue the error that bubbles up after the final retry attempt is made. Please see my comments and code snippets below. Source…
17
votes
4 answers

How can I run an ActiveJob in Rails console for debugging?

I currently have an ActiveJob that I've created and use Sidekiq to queue it. I'm wanting to debug the job, but for me to see any messages I program into it I have to check my log files. I feel like it would be more convenient to be able to see my…
daveomcd
  • 6,367
  • 14
  • 83
  • 137
17
votes
2 answers

Rails 4.2 - Sidekiq not sending emails in development

I have a rails app in which I have a method where I send a lot of emails. I would like to perform this action asynchronously. To do it I've tried to use Sidekiq, but I can't get it to work properly - it doesn't send any emails. Sending email worked…
Anders
  • 2,903
  • 7
  • 58
  • 114
17
votes
4 answers

Rails 4.2: using deliver_later with a tableless model

I am trying to setup a contact form using Rails 4.2's deliver_later method. However, I can only get deliver_now to work, as deliver_later is trying to serialize my object and fails each time. Here's my setup: messages_controller.rb class…
DaniG2k
  • 4,772
  • 36
  • 77
16
votes
1 answer

ActiveJob::SerializationError - Unsupported argument type: Time / DateTime

I am using Rails 5 and ActiveJob to process background tasks. I am trying to pass a object serialized with as_json to my job but I am receiving the following errors: ActiveJob::SerializationError (Unsupported argument type:…
Arthur
  • 1,970
  • 4
  • 18
  • 19
16
votes
7 answers

How do I filter or remove logging of ActiveJob arguments?

I'm using Rails' ActiveJob, and one of my jobs take a raw email as input. When debugging, this can result in a huge amount of noise in my application log. How can I avoid that? [ActiveJob] Enqueued EmailParserJob (Job ID:…
Jeppe Liisberg
  • 3,734
  • 3
  • 25
  • 24
15
votes
1 answer

SerializationError Rails ActiveJob Time and Date

Anyone know of a clean way to avoid the ActiveJob::SerializationError that occurs when trying to serialize a Date or Time object? The two solutions I've had so far are to: Call Marshal/JSON/YAML dump when loading the arguments and then load back in…
kddeisz
  • 5,162
  • 3
  • 21
  • 44
1
2 3
31 32