-
Notifications
You must be signed in to change notification settings - Fork 302
Open
Description
Hi there.
Actually, you almost don't need resilience4j. I have seen the latest Sergey's implementation, but I decided to stick to what I had seen in the video with Hystrix
pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
</dependency>
Then, you need to enable fallback as it is suggested in the video though it has slightly different parameters:
In the application.properties / application.yml of the PhotoAppApiUsers set the following:
spring:
cloud:
openfeign:
circuitbreaker:
enabled: true
I would also suggest switching to the ERROR mode.
logging:
level:
com:
appsdeveloperblog:
photoapp:
api:
users:
client:
AlbumsServiceClient: ERROR
I couldn't have figured out as to why I see an exception. The result was completely different from what Sergey gets in the video.
Finally, when I change the DEBUG to ERROR mode my console is clean now.
The last step is quite the same as you see in the video.
@FeignClient(name = "albums-ws", fallback = AlbumsFallback.class)
public interface AlbumsServiceClient {
@GetMapping("/users/{id}/albums")
List<AlbumResponseModel> getAlbums(@PathVariable String id);
}
@Component
class AlbumsFallback implements AlbumsServiceClient {
@Override
public List<AlbumResponseModel> getAlbums(String id) {
return new ArrayList<>();
}
}
Metadata
Metadata
Assignees
Labels
No labels
