Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delayed job vs Active job

What is the difference between delayed job and active job in Ruby on Rails? Why should I use delayed job if active job is present? I have tried to find some more information but I have not been successful.

like image 805
George Morris Avatar asked Apr 03 '18 16:04

George Morris


People also ask

What is delayed job?

Delayed Job, also known as DJ, makes it easy to add background tasks to your Rails applications on Heroku. You can also use Resque and many other popular background queueing libraries. Delayed Job uses your database as a queue to process background jobs.

What is an active job?

An active job allows you to stay moving, helping you maintain or improve your physical health during your daily responsibilities. Improved mental health: Active jobs provide your brain with added stimulation. Since many active jobs take place outdoors, you can receive more exposure to vitamin D.

How do I check if my job is delayed?

The most simple way to check whether delayed_job is running or not, is to check at locked_by field. This field will contain the worker or process locking/processing the job. Running Delayed::Job. where('locked_by is not null') will give you some results, if there are jobs running.

How do you restart a delayed job?

Restart Delayed Job on deploy You must remove that one now if you have it. It basically does the same thing that we will add now but without using upstart. We will now create a new file that will host our start, stop and restart tasks. Create a file at lib/capistrano/tasks/delayed_job.


1 Answers

ActiveJob is very similar idea to ActiveRecord.

ActiveRecord is a wrapper. You can write code for it and then it decides how to execute it, depending which backend you're using.

ActiveJob is just another wrapper. In this case DelayedJob would be the backend that actually runs jobs. If down the road you decide to switch to something like Resque or Sidekiq, all your code should still work because translation is handled by ActiveJob wrapper

like image 66
Ruslan Avatar answered Sep 28 '22 16:09

Ruslan