You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-25Lines changed: 29 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,29 +2,11 @@
2
2
3
3
Solid Queue is a DB-based queuing backend for [Active Job](https://edgeguides.rubyonrails.org/active_job_basics.html), designed with simplicity and performance in mind.
4
4
5
-
Besides regular job enqueuing and processing, Solid Queue supports delayed jobs, concurrency controls, pausing queues, numeric priorities per job, and priorities by queue order. _Proper support for `perform_all_later`, improvements to logging and instrumentation, a better CLI tool, a way to run within an existing process in "async" mode, unique jobs and recurring, cron-like tasks are coming very soon._
5
+
Besides regular job enqueuing and processing, Solid Queue supports delayed jobs, concurrency controls, pausing queues, numeric priorities per job, and priorities by queue order. _Improvements to logging and instrumentation, a better CLI tool, a way to run within an existing process in "async" mode, unique jobs and recurring, cron-like tasks are coming very soon._
6
6
7
7
Solid Queue can be used with SQL databases such as MySQL, PostgreSQL or SQLite, and it leverages the `FOR UPDATE SKIP LOCKED` clause, if available, to avoid blocking and waiting on locks when polling jobs. It relies on Active Job for retries, discarding, error handling, serialization, or delays, and it's compatible with Ruby on Rails multi-threading.
8
8
9
-
## Usage
10
-
To set Solid Queue as your Active Job's queue backend, you should add this to your environment config:
11
-
```ruby
12
-
# config/environments/production.rb
13
-
config.active_job.queue_adapter =:solid_queue
14
-
```
15
-
16
-
Alternatively, you can set only specific jobs to use Solid Queue as their backend if you're migrating from another adapter and want to move jobs progressively:
17
-
18
-
```ruby
19
-
# app/jobs/my_job.rb
20
-
21
-
classMyJob < ApplicationJob
22
-
self.queue_adapter =:solid_queue
23
-
# ...
24
-
end
25
-
```
26
-
27
-
## Installation
9
+
## Installation and usage
28
10
Add this line to your application's Gemfile:
29
11
30
12
```ruby
@@ -41,23 +23,43 @@ Or install it yourself as:
41
23
$ gem install solid_queue
42
24
```
43
25
44
-
Install Migrations and Set Up Active Job Adapter
45
-
Now, you need to install the necessary migrations and configure the Active Job's adapter. Run the following commands:
26
+
Now, you need to install the necessary migrations and configure the Active Job's adapter. You can do both at once using the provided generator:
27
+
46
28
```bash
47
29
$ bin/rails generate solid_queue:install
48
30
```
49
31
50
-
or add the only the migration to your app and run it:
32
+
This will set `solid_queue` as the Active Job's adapter in production, and will copy the required migration over to your app.
33
+
34
+
Alternatively, you can add the only the migration to your app:
51
35
```bash
52
36
$ bin/rails solid_queue:install:migrations
53
37
```
54
38
55
-
Run the Migrations (required after either of the above steps):
39
+
And set Solid Queue as your Active Job's queue backend manually, in your environment config:
40
+
```ruby
41
+
# config/environments/production.rb
42
+
config.active_job.queue_adapter =:solid_queue
43
+
```
44
+
45
+
Alternatively, you can set only specific jobs to use Solid Queue as their backend if you're migrating from another adapter and want to move jobs progressively:
46
+
47
+
```ruby
48
+
# app/jobs/my_job.rb
49
+
50
+
classMyJob < ApplicationJob
51
+
self.queue_adapter =:solid_queue
52
+
# ...
53
+
end
54
+
```
55
+
56
+
Finally, you need to run the migrations:
57
+
56
58
```bash
57
59
$ bin/rails db:migrate
58
60
```
59
61
60
-
With this, you'll be ready to enqueue jobs using Solid Queue, but you need to start Solid Queue's supervisor to run them.
62
+
After this, you'll be ready to enqueue jobs using Solid Queue, but you need to start Solid Queue's supervisor to run them.
61
63
```bash
62
64
$ bundle exec rake solid_queue:start
63
65
```
@@ -83,6 +85,7 @@ production:
83
85
dispatchers:
84
86
- polling_interval: 1
85
87
batch_size: 500
88
+
concurrency_maintenance_interval: 300
86
89
workers:
87
90
- queues: "*"
88
91
threads: 3
@@ -97,6 +100,7 @@ Everything is optional. If no configuration is provided, Solid Queue will run wi
97
100
98
101
- `polling_interval`: the time interval in seconds that workers and dispatchers will wait before checking for more jobs. This time defaults to `1` second for dispatchers and `0.1` seconds for workers.
99
102
- `batch_size`: the dispatcher will dispatch jobs in batches of this size. The default is 500.
103
+
- `concurrency_maintenance_interval`: the time interval in seconds that the dispatcher will wait before checking for blocked jobs that can be unblocked. Read more about [concurrency controls](#concurrency-controls) to learn more about this setting. It defaults to `600` seconds.
100
104
- `queues`: the list of queues that workers will pick jobs from. You can use `*` to indicate all queues (which is also the default and the behaviour you'll get if you omit this). You can provide a single queue, or a list of queues as an array. Jobs will be polled from those queues in order, so for example, with `[ real_time, background ]`, no jobs will be taken from `background` unless there aren't any more jobs waiting in `real_time`. You can also provide a prefix with a wildcard to match queues starting with a prefix. For example:
0 commit comments