私の Java アプリケーションには、リモート呼び出しの失敗に対する再試行ロジックが必要です。これらのリモート呼び出しは次のとおりです。
- アプリケーション全体に散らばる
- さまざまなリモート サービス クラスに関連します。
また、再試行ロジックには、さまざまな再試行間隔とさまざまな再試行が含まれる場合があります。
どこから呼び出されたかに応じて適切なメソッド呼び出しを行うことができる汎用の retry() 実装が必要です。以下は、私が探している簡単なコード図です。Java リフレクションを使用してこれを実行できることはわかっていますが、どこかで使用できるフレームワークまたはオープン ソースはありますか?
try {
ClassA objA = remoteServiceA.call(paramA1, paramA2, ...);
} catch (Exception e){
ClassA objA = (ClassA)retry(remoteService, listOfParams, ..); // generic method call
}
..
try {
ClassB objB = remoteServiceB.call(paramB1, paramB2, ...);
} catch (Exception e){
ClassA objB = (ClassB)retry(remoteService, listOfParams, ..); // generic method call
}