question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question regarding resilience4j-spring-cloud2 usage

See original GitHub issue

Resilience4j version: 1.3.1

Java version: 1.8

I have added resilience4j-spring-cloud2, spring-boot-starter-actuator, spring-boot-starter-aop, to pom.xml and also added config server details to bootstrap.properties. At runtime I have changed a property and ran /actuator/refresh, which returned the modified properties as response like below.

[
    "resilience4j.threadPoolBulkhead.configs.default.maxThreadPoolSize"
]

I have also written test endpoint /ping/prop which returns the value of resilience4j.bulkhead.max.thread.pool.size to make sure refresh is working as expected.

@Value("${resilience4j.threadPoolBulkhead.configs.default.maxThreadPoolSize}")
private String maxThreadPoolSize;

However When I have used /actuator/metrics/resilience4j.bulkhead.max.thread.pool.size I don’t see the refreshed value is getting reflected in measurements. I also observed when doing refresh the debugger it’s going to AbstractRefreshScopedBulkheadConfiguration.threadPoolBulkheadRegistry() method though it’s annotated with @RefreshScope. Am I missing something here? I have also checked the demo project https://github.com/resilience4j/resilience4j-spring-cloud2-demo for usage, didn’t find any clue.

FYI, I have some default properties in application.properties, and the plan is to provide different values per environment via centralized configuration.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
dlsrb6342commented, Jun 4, 2020

Yes. I tested with following changes.

// Added to CheckService
	@Bulkhead(name = "test", type = Type.THREADPOOL)
	public CompletableFuture<Map<String, Number>> checkFuture() {
		return CompletableFuture.supplyAsync(this::check);
	}

Test result

  1. Check with API call
▶ curl http://127.0.0.1:8080/checkFuture
{"ThreadPoolBulkhead max thread pool":4,"Bulkhead maxConcurrentCalls":100,"Retry max retry":2,"CircuitBreaker failureRateThreshold":30.0,"RateLimiter limitForPeriod":10}%

// Changed to 10
▶ curl -X POST http://127.0.0.1:8080/actuator/refresh
["resilience4j.thread-pool-bulkhead.configs.default.maxThreadPoolSize"]%

▶ curl http://127.0.0.1:8080/checkFuture
{"ThreadPoolBulkhead max thread pool":10,"Bulkhead maxConcurrentCalls":100,"Retry max retry":2,"CircuitBreaker failureRateThreshold":30.0,"RateLimiter limitForPeriod":10}%
  1. Check with actuator metrics. You need to call API once because Bulkhead instance should be re-created.
▶ curl http://127.0.0.1:8080/actuator/metrics/resilience4j.bulkhead.max.thread.pool.size
{"name":"resilience4j.bulkhead.max.thread.pool.size","description":"The maximum thread pool size","baseUnit":null,"measurements":[{"statistic":"VALUE","value":10.0}],"availableTags":[{"tag":"name","values":["test"]}]}%

// Changed to 4
▶ curl -X POST http://127.0.0.1:8080/actuator/refresh
["resilience4j.thread-pool-bulkhead.configs.default.maxThreadPoolSize"]%

▶ curl http://127.0.0.1:8080/checkFuture
{"ThreadPoolBulkhead max thread pool":4,"Bulkhead maxConcurrentCalls":100,"Retry max retry":2,"CircuitBreaker failureRateThreshold":30.0,"RateLimiter limitForPeriod":10}%

▶ curl http://127.0.0.1:8080/actuator/metrics/resilience4j.bulkhead.max.thread.pool.size
{"name":"resilience4j.bulkhead.max.thread.pool.size","description":"The maximum thread pool size","baseUnit":null,"measurements":[{"statistic":"VALUE","value":4.0}],"availableTags":[{"tag":"name","values":["test"]}]}%
1reaction
dlsrb6342commented, Jun 3, 2020

@Romeh Yes right.

Metric response is like following.

▶ curl http://127.0.0.1:8080/actuator/metrics/resilience4j.bulkhead.max.thread.pool.size
{
   "name":"resilience4j.bulkhead.max.thread.pool.size",
   "description":"The maximum thread pool size",
   "baseUnit":null,
   "measurements":[
      {
         "statistic":"VALUE",
         "value":4.0
      }
   ],
   "availableTags":[
      {
         "tag":"name",
         "values":[
            "test"
         ]
      }
   ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Retry with Spring Boot and Resilience4j - Reflectoring
A deep dive into the Spring Boot Resilience4j Retry module, this article shows why, when and how to use it to build resilient...
Read more >
Spring Cloud Gateway with Resilience4J Circuit Breaker did ...
While attempting to integrate Resilience4J with Spring Cloud Gateway, some features such as retry appear to be working properly, ...
Read more >
Getting Started | Spring Cloud Circuit Breaker Guide
Spring Cloud Circuit Breaker supports many different circuit breaker implementations including, Resilience4J, Hystrix, Sentinal, and Spring Retry. In this guide ...
Read more >
Getting Started - resilience4j
Add the Spring Cloud 2 Starter of Resilience4j to your compile dependency. The Spring Cloud 2 Starter allows you to use Spring Cloud...
Read more >
Circuit Breaking In Spring Cloud Gateway With Resilience4J
In these five attempts, we get only 2 timeouts, since we set 5 repeats for delayed service on the mock server and the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found