Created
December 5, 2021 10:02
-
-
Save HVHO/ad928339b11b16b733506daf0769a872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
class RetryableService { | |
@Autowired | |
private lateinit var retryTemplate: RetryTemplate | |
@Retryable | |
fun doWithRetry() : Unit { | |
randomFail() | |
} | |
private fun randomFail(): Unit { | |
if (random() > 0.1) { | |
println("failed!") | |
throw RuntimeException("failed!") | |
} else { | |
println("success!") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment