I wonder if I succeeded to get Delayed::Job working. Can't see jobs in the delayed_jobs
table.
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With