キーワード†
- リトライ
- Kotlin
- spring-retry
したいこと†
Kotlinでspring-retryを使ってリトライ処理したい(ができない、を解決)。
どうやって†
@Component @EnableRetry class SomeComponent { @Retryable(value = [UserException::class]) @Throws(UserException::class) // ポイント fun doSomething(param: UserParam) { ... } @Recover fun recover(e: UserException, param: UserParam) { ... } }
ちなみに†
Kotlinでは@ThrowsをつけないとUndeclaredThrowableExceptionで片付けられてしまう。
Cannot locate recovery method; nested exception is java.lang.reflect.UndeclaredThrowableException