@@ -64,9 +64,33 @@ TODO: Add description https://github.com/rails/rails/pull/43945
64
64
65
65
TODO: Add description https://github.com/rails/rails/pull/44189
66
66
67
- ### Add `perform_all_later`` to enqueue multiple jobs at once
67
+ ### Add ` perform_all_later ` to enqueue multiple jobs at once
68
68
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.
70
94
71
95
### Composite primary keys
72
96
0 commit comments