Web サービスを消費し、エラー処理を追加したいデータベースと通信する Workflow Foundation 4.0 RC コード アクティビティがたくさんあります。
Web サービス / db を呼び出して、通信障害などの障害をキャッチし、(例外をログに記録した後) 1 時間以内に同じ操作を再試行できるようにしたいと考えています。
このようなことをする方法はありますか?
protected override void Execute(CodeActivityContext context) {
Persist(); // I would like to invoke the persist activity like this
if (!AttemptServiceCall()) {
// I would like to invoke a delay activity like this
Delay(new TimeSpan(0, 30, 0)); // wait 30 mins before trying again
Execute(context); // call this activity again
}
}
private bool AttemptServiceCall() {
bool serviceCallSuccessful = true;
try {
myService.InvokeSomeMethod();
}
catch (CommunicationException ex) {
myEventLogger.Log(ex);
serviceCallSuccessful = false;
}
return serviceCallSuccessful;
}