I am considering using Sidekiq::Batch
and learning from the following reference: https://github.com/sidekiq/sidekiq/wiki/Batches
I would like to know if the following is possible and what would happen in that case:
In the example below, I schedule a job using perform_in
inside a batch.
The last of MyJob should be executed 5 hours later.
batch = Sidekiq::Batch.new
batch.on(:success, MyCallback)
batch.jobs do
5.times do |index|
MyJob.perform_in((1 * index).hour, args)
end
end
By setting batch.on(:success, MyCallback)
, I can do something after all jobs have completed.
Here, All jobs should be completed in 5 hours and a few minutes.
My questions are:
- In this case, will the callback fire correctly after all jobs are completed in 5 hours and a few minutes (all job completed)?
- In that case, where is the batch waiting and how can the batch know the all job has been completed?
- Are there any negative effects if there are many batches waiting for a long time like this?
I appreciate any help as I am not familiar with Sidekiq, thank you in advance.