feat: add resilience4j retry configuration

This commit is contained in:
Rodrigo Verdiani 2025-10-27 15:13:24 -03:00
parent 948dd7fb9e
commit 6b2a77b391
4 changed files with 28 additions and 0 deletions

View File

@ -125,6 +125,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.resilience4j/resilience4j-spring-boot3 -->
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot3</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>

View File

@ -2,12 +2,15 @@ package com.magamochi.mangamochi.client;
import java.time.OffsetDateTime;
import java.util.List;
import io.github.resilience4j.retry.annotation.Retry;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "jikan", url = "https://api.jikan.moe/v4/manga")
@Retry(name = "JikanRetry")
public interface JikanClient {
@GetMapping
SearchResponse mangaSearch(@RequestParam String q);

View File

@ -3,10 +3,13 @@ package com.magamochi.mangamochi.client;
import com.magamochi.mangamochi.model.dto.MangaDexMangaDTO;
import java.util.List;
import java.util.UUID;
import io.github.resilience4j.retry.annotation.Retry;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@FeignClient(name = "mangaDex", url = "https://api.mangadex.org")
@Retry(name = "MangaDexRetry")
public interface MangaDexClient {
@GetMapping("/manga/{id}")
MangaDexMangaDTO getManga(@PathVariable UUID id);

View File

@ -51,3 +51,19 @@ jwt:
manga-matcher:
endpoint: ${MANGAMATCHER_ENDPOINT}
resilience4j:
retry:
instances:
MangaDexRetry:
max-attempts: 5
wait-duration:
seconds: 5
retry-exceptions:
- feign.FeignException
JikanRetry:
max-attempts: 5
wait-duration:
seconds: 5
retry-exceptions:
- feign.FeignException