Skip to content
/ pg_jobs Public

Simple ActiveJob queue for PostgreSQL using LISTEN/NOTIFY

License

Notifications You must be signed in to change notification settings

mbreit/pg_jobs

Repository files navigation

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'

Configuration

You can set the logger for pg_jobs with PgJobs.logger=:

PgJobs.logger = Logger.new(STDOUT)
PgJobs.logger.level = :debug

It will use ActiveJob::Base.logger by default.

Note: This does not change the logging behaviour of your jobs, only the log statements of pg_jobs itself.

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.

About

Simple ActiveJob queue for PostgreSQL using LISTEN/NOTIFY

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages