【发布时间】:2019-07-30 13:08:03
【问题描述】:
我想在我的应用程序启动后调用一些代码。有没有办法处理事件:
Started SomeApp in 14.905 seconds (JVM running for 16.268)
如果另一个应用程序启动,我将尝试。我尝试使用 Retryable 但未在应用程序启动之前执行它并引发异常以便应用程序退出。
@EventListener
fun handleContextRefresh(event: ContextRefreshedEvent) {
retryableInvokeConnection()
}
@Retryable(
value = [RetryableException::class, ConnectionException::class],
maxAttempts = 100000,
backoff = Backoff(delay = 5)
)
private fun retryableInvokeConnection() {
}
@Recover
private fun retryableInvokeConnectionExceptionHandler(ex: ConnectionException) {
}
也许我应该使用 PostConstruct 和 while 循环。
【问题讨论】:
标签: spring spring-cloud-feign spring-retry