2016-05-31 40 views
0
batch = Sidekiq::Batch.new 
batch.description = "Batch description (this is optional)" 
batch.on(:success, MyCallback, :to => user.email) 
batch.jobs do 
    rows.each { |row| RowWorker.perform_async(row) } 
end 

sleep(x_seconds) 

batch.jobs do 
    rows.each { |row| RowWorker.perform_async(row) } 
end 

puts "Just started Batch #{batch.bid}" 

在上面的代码中,可能会在添加下一个批处理作业之前调用回调..因此有办法通知sidekiq pro不要调用回调,因为批处理中的作业尚未被添加?sidekiq如何知道批次的所有工作?

回答

2

不,你不能那样做。完成第一个作业块后,除批处理中的另一个作业外,不能安全地向批处理中添加更多作业。

+0

很酷..谢谢:) – david

相关问题