2016-05-31 39 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

相關問題