Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see the delayed job queue?

I wonder if I succeeded to get Delayed::Job working. Can't see jobs in the delayed_jobs table.

  • Is that normal?
  • Is there any other ways too see job queue?
like image 963
knotito Avatar asked Sep 01 '13 22:09

knotito


People also ask

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 does Delayed Job work?

Delayed::Job works by serializing a Ruby object as YAML and storing it in a database table so that a worker in a different process can retrieve, deserialize, and perform the requested work. Some operations that we use Delayed::Job for are longer-running data processing, sending emails, and updating search indicies.

What is Delayed Job in Rails?

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 Activejob when should we use it?

Active Job is a framework for declaring jobs and making them run on a variety of queueing backends. 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.


2 Answers

DelayedJob stores a database record for each enqueued job so you can retrieve them directly through the rails console (assuming you are using ActiveRecord or similar).

Open the rails console:

$ rails c 

and then query the enqueued jobs:

$ Delayed::Job.all 

or

$ Delayed::Job.last 

Check out the documentation.

If you installed delayed_job with another database like Redis you may want to go and check in there the queued jobs.

like image 85
Nicolas Garnil Avatar answered Sep 25 '22 21:09

Nicolas Garnil


You should see jobs in the delayed_jobs table, yes. But when delayed jobs are run successfully they're deleted. So it may just be a fleeting thing. (Delayed Job checks the table for new jobs to run every 5 seconds, so the record may only last a few seconds on average given a short-running job.) I usually make sure the delayed job daemon is turned off if I want to inspect the payload objects in the delayed_jobs table.

like image 27
pdobb Avatar answered Sep 23 '22 21:09

pdobb