1
0
mirror of https://github.com/pcvolkmer/etl-processor.git synced 2025-07-06 00:12:53 +00:00

feat: do not retry on validation issues (#89)

This will prevent retry if response is HTTP 400 or HTTP 422.
This commit is contained in:
2025-03-23 13:35:24 +01:00
committed by GitHub
parent 56a63b276e
commit 98b971d7db
2 changed files with 12 additions and 4 deletions

View File

@ -55,6 +55,7 @@ import org.springframework.retry.support.RetryTemplateBuilder
import org.springframework.scheduling.annotation.EnableScheduling
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.security.provisioning.InMemoryUserDetailsManager
import org.springframework.web.client.HttpClientErrorException
import org.springframework.web.client.RestTemplate
import reactor.core.publisher.Sinks
import java.io.BufferedInputStream
@ -224,6 +225,8 @@ class AppConfiguration {
fun retryTemplate(configProperties: AppConfigProperties): RetryTemplate {
return RetryTemplateBuilder()
.notRetryOn(IllegalArgumentException::class.java)
.notRetryOn(HttpClientErrorException.BadRequest::class.java)
.notRetryOn(HttpClientErrorException.UnprocessableEntity::class.java)
.exponentialBackoff(2.seconds.toJavaDuration(), 1.25, 5.seconds.toJavaDuration())
.customPolicy(SimpleRetryPolicy(configProperties.maxRetryAttempts))
.withListener(object : RetryListener {