Gem license MIT build maintainability coverage docs

PgJobs

Simple Active Job worker for PostgreSQL using LISTEN/NOTIFY and SKIP LOCKED.

Supports most Active Job features like multiple queues, priorities and wait times.

Dependencies

  • PostgreSQL >= 9.5 to use SKIP LOCKED
  • Ruby >= 2.3
  • Rails >= 5.1

Installation

Add this line to your application's Gemfile:

gem 'pg_jobs'

And then execute:

bundle

Then copy the migrations and migrate your database:

bin/rails pg_jobs_engine:install:migrations
bin/rails db:migrate

To configure the Active Job adapter add this to your environment configuration (config/environments/production.rb):

config.active_job.queue_adapter = :pg_jobs

If you want to run all your jobs in one queue, we recommend to configure ActionMailer to use the default queue:

config.action_mailer.deliver_later_queue_name = 'default'

Usage

Just schedule your work with Active Job, then run one or multiple workers for the default queue with

bin/rails runner PgJobs.work

or for other queues with

bin/rails runner "PgJobs.work(:my_queue)"

For more documentation about Active Job and how to use different queues, scheduled jobs, priorities and error handling, see the Active Job Rails Guide.

Contributing

Use Github issues and pull requests.

License

The gem is available as open source under the terms of the MIT License.