Skip to content

Instantly share code, notes, and snippets.

View HVHO's full-sized avatar

DongHyun Kim HVHO

View GitHub Profile
@Retryable()
fun doWithRetry(input : String) {
// do something
}
@Recover
fun recover(exception: RuntimeException, input : String) : Unit {
// do someThing
}
public interface RetryListener {
<T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback);
<T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable);
<T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable);
}
@Retryable(backoff = Backoff(2000))
fun doWithRetry() {
// do something
}
@Retryable(include = [RuntimeException::class, IllegalStateException::class])
fun doWithRetry() {
// do something
}
@Service
class RetryableService {
@Autowired
private lateinit var retryTemplate: RetryTemplate
@Retryable
fun doWithRetry() : Unit {
randomFail()
}
@SpringBootApplication
@EnableRetry
class RetryTestApplication
fun main(args: Array<String>) {
// main function
}
implementation("org.springframework.retry:spring-retry")
implementation("org.springframework:spring-aspects")
@Service
class RetryableService {
@Retryable
fun run() : Unit {
action()
}
}
@Service
class RetryableService {
@Autowired
private lateinit var retryTemplate: RetryTemplate
fun run() : Unit {
retryTemplate.execute<Unit, Throwable> {
action()
}
@Service
class RetryableService {
@Autowired
private lateinit var retryTemplate: RetryTemplate
fun run() : Unit {
retryTemplate.execute<Unit, Throwable> {
action()
}