リトライスコープで、BusinessRuleExceptionの場合だけ、リトライせずにスローしたい

リトライスコープアクティビティでは、例外が発生した場合にリトライされますが、
BusinessRuleExceptionの場合はリトライせずにスローしたいのです。
スマートなやり方はありますでしょうか?

※もちろん、毎回BusinessRuleExceptionをさせてリトライ回数分待てば良いのですが、
無駄な気がして…、他のやり方は無いかなぁ?と思った次第です。

※BusinessRuleException以外の場合は通常通りリトライしたいのです。

こんにちは

例えば
リトライスコープ内部でTryCatchを配置
CatchでBusinessRuleExceptionはその内容だけを外に渡せるようにして、正常終了させる
その他のExceptionはRethrow
でいかがでしょうか?以下実装イメージです。

1 Like

Hi @ta.shiraki

Retry Scope (NumberOfRetries = 3, RetryInterval = 00:00:05)
 Try
     Your activities that might throw exceptions

 Catch (Exception)
     If 
      condition: exception.GetType() = GetType(BusinessRuleException))
     Then
       Rethrow (re-throw the BusinessRuleException without retry)
     Else
       Log Message (log the exception details)
       Throw (re-throw the exception to trigger the retry)

 Continue with your workflow
1 Like

ありがとうございます!
良いですね!助かりましたm(_ _)m

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.