Skip to content

This project aims at demonstrating how to use resillience4j in a spring boot app.

License

Notifications You must be signed in to change notification settings

pictet-technologies-open-source/resilience4j

Repository files navigation

CircleCI CodeFactor License: MIT

Made with Love by Pictet Technologies LinkedIn

resilience4j

This project aims at demonstrating how to use resillience4j in a spring boot app.

Compile the application

$ mvn clean install

Start the application

Prometheus and Grafana

$ cd docker
$ docker-compose up

In Grafana you will have to create a new dashboard and import the file docker/grafana.json

Start the exchange rate webservice

$ cd resilience4j-exchange-rate-proxy
$ mvn spring-boot:run

Start the resilient store webservice

$ cd resilience4j-store-app
$ mvn spring-boot:run

Start the UI

$ cd resilience4j-store-ui
$ npm start

URLs

Call the application using Apache HTTP Server benchmarking tool

$ ab -n x -c y 'http://127.0.0.1:4200/items?currency=GBP'

where x is the total number of calls and y the number of concurrent users

Tests

Retry


Given

the exchange rate service is UP

When

$ ab -n 1 -c 1  'http://127.0.0.1:4200/items?currency=GBP'

Then

The call is successful


Given

the exchange rate service is DOWN

When

$ ab -n 1 -c 1  'http://127.0.0.1:4200/items?currency=GBP'

Then

The call is successful with the fallback applied after x retries

Circuit breaker


Given

the exchange rate service is UP

When

$ ab -n 10 -c 1  'http://127.0.0.1:4200/items?currency=GBP'

Then

The call is successful


Given

the exchange rate service is DOWN

When

$ ab -n 20 -c 1  'http://127.0.0.1:4200/items?currency=GBP'

Then

The calls are successful using the circuit breaker fallback The circuit is open

Bulk head

Given

the exchange rate service is UP and the rate limiter is disabled

When

$ ab -n 100 -c 10  'http://127.0.0.1:4200/items?currency=GBP'

Then

The calls are successful


Given

the exchange rate service is UP and the rate limiter is disabled

When

$ ab -n 100 -c 11  'http://127.0.0.1:4200/items?currency=GBP'

Then

The calls are successful, but the fallback has been used for some calls

Rate limiter

Given

the exchange rate service is UP

When

$ ab -n 10 -c 1  'http://127.0.0.1:4200/items?currency=GBP'

Then

The calls are successful


Given

the exchange rate service is UP

When

$ ab -n 20 -c 1  'http://127.0.0.1:4200/items?currency=GBP'

Then

The calls are successful, but the fallback has been called for half of them

References