Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ActiveJob have queues with specific priority?

Looking at the job below I would assume the job runs on a low_priority queue.

class GuestsCleanupJob < ActiveJob::Base
  queue_as :low_priority
  #....
end

I would agree with this, but this is just the name of the queue correct? It actually has nothing to do with priority. For example if I created a job with a queue named :my_queue it would be treated as having the same priority as a :low_priority queue.

From the documentation I haven't been able to find anything indicating that I can prioritize jobs that are queued. I know delayed_jobs has this functionality, but I haven't found it in active_job.

like image 290
Ryan-Neal Mes Avatar asked Sep 09 '15 13:09

Ryan-Neal Mes


People also ask

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.

How do I change my job priority?

Expand Work Management > All Tasks > Job Queues > Active Job Queues or All Job Queues > The job queue in which your job is located. Right-click the job and click Properties. On the Job - Properties window, click the Job Queue tab. From the Priority on job queue list, select a higher (or lower) priority number.

How do I enqueue a job in rails?

Enqueue jobs The different enqueuing options are the following: wait : With this, the job is enqueued after the mentioned time period. wait_until : With this, the job is enqueued after that the specified time has elapsed. queue : With this, the job is added to the specified queue.

What is background job rails?

Running Background Jobs in Ruby on Rails Containers – DevGraph. Products. SCALEARC. A SQL load balancer that enables you to dramatically scale and improve database performance without any code changes to your application or database.


1 Answers

Priority depends on actual QueueAdapter and how this adapter was configured. If your adapter does not support priorities or was not properly configured, then ActiveJob can't help you either.

Find out more details about adapters from here:

http://edgeapi.rubyonrails.org/classes/ActiveJob/QueueAdapters.html

The main takeaway is this:

The main point is to ensure that all Rails apps will have a job infrastructure in place. We can then have framework features and other gems build on top of that, without having to worry about API differences between various job runners such as Delayed Job and Resque. Picking your queuing backend becomes more of an operational concern, then. And you'll be able to switch between them without having to rewrite your jobs.

Queue configuration (including priorities) becomes Adapter's responsibility.

As an example of queue configuration see Sidekiq wiki:

https://github.com/mperham/sidekiq/wiki/Advanced-Options#queues

like image 131
dimakura Avatar answered Oct 03 '22 08:10

dimakura