def perform
  refund_log = {
    success: refund_retry.success?,
    amount: refund_amount,
    action: "refund"
  }
  if refund_retry.success?
    refund_log[:reference] = refund_retry.transaction.id
    refund_log[:message] = refund_retry.transaction.status
  else
    refund_log[:message] = refund_retry.message
    refund_log[:params] = {}
    refund_retry.errors.each do |error|
      refund_log[:params][error.code] = error.message
    end
    order_transaction.message = refund_log[:params].values.join('|')
    raise "delayed RefundJob has failed"
  end
end

当我在else语句中引发“延迟的RefundJob失败”时,它将创建一个Airbrake。如果要在else部分中结束,我想再次运行该作业。

有什么方法可以在不引发异常的情况下重新排队工作?并防止产生刹车?

我正在使用delay_job版本1。

最佳答案

最干净的方法是重新排队,即创建一个新作业并将其排队,然后正常退出该方法。

关于ruby - 每次出现错误时,作业延迟创建Airbrakes,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12804903/

10-15 14:18