Skip to content

Commit fcda3a8

Browse files
authored
Merge pull request rails#49034 from akhilgkrishnan/perform_all_later_to_relase_note_7_1
[skip ci] Add description for perform_all_later method in 7.1 release note
2 parents 4aa1625 + 26931de commit fcda3a8

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

guides/source/7_1_release_notes.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,33 @@ TODO: Add description https://github.com/rails/rails/pull/43945
6464

6565
TODO: Add description https://github.com/rails/rails/pull/44189
6666

67-
### Add `perform_all_later`` to enqueue multiple jobs at once
67+
### Add `perform_all_later` to enqueue multiple jobs at once
6868

69-
TODO: Add description https://github.com/rails/rails/pull/46603
69+
The [`perform_all_later` method in ActiveJob](https://github.com/rails/rails/pull/46603),
70+
designed to streamline the process of enqueuing multiple jobs simultaneously. This powerful
71+
addition allows you to efficiently enqueue jobs without triggering callbacks. This is
72+
particularly useful when you need to enqueue a batch of jobs at once, reducing the overhead
73+
of multiple round-trips to the queue datastore.
74+
75+
Here's how you can take advantage of `perform_all_later`:
76+
77+
```ruby
78+
# Enqueueing individual jobs
79+
ActiveJob.perform_all_later(MyJob.new("hello", 42), MyJob.new("world", 0))
80+
81+
# Enqueueing an array of jobs
82+
user_jobs = User.pluck(:id).map { |id| UserJob.new(user_id: id) }
83+
ActiveJob.perform_all_later(user_jobs)
84+
```
85+
86+
By utilizing `perform_all_later`, you can optimize your job enqueuing process and take advantage
87+
of improved efficiency, especially when working with large sets of jobs. It's worth noting that
88+
for queue adapters that support the new `enqueue_all` method, such as the Sidekiq adapter, the
89+
enqueuing process is further optimized using `push_bulk`.
90+
91+
Please be aware that this new method introduces a separate event, `enqueue_all.active_job`,
92+
and does not utilize the existing `enqueue.active_job` event. This ensures accurate tracking
93+
and reporting of the bulk enqueuing process.
7094

7195
### Composite primary keys
7296

0 commit comments

Comments
 (0)