Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to check thread-pool-bulkhead health? #75

Open
geekxingyun opened this issue Jan 8, 2024 · 1 comment
Open

how to check thread-pool-bulkhead health? #75

geekxingyun opened this issue Jan 8, 2024 · 1 comment

Comments

@geekxingyun
Copy link

geekxingyun commented Jan 8, 2024

i had config these code in yaml file,but it not effected when i use 20 concurrent call with jmeter.

how can i check these issue?

resilience4j.thread-pool-bulkhead:
    instances:
      default:
        max-thread-pool-size: 1
        core-thread-pool-size: 1
        queue-capacity: 1
      singleAnalysisThreadPoolBulkhead:
        max-thread-pool-size: 1
        core-thread-pool-size: 1
        queue-capacity: 1
        keep-alive-duration: 1ms
        writable-stack-trace-enabled: true
      batchAnalysisThreadPoolBulkhead:
        max-thread-pool-size: 5
        core-thread-pool-size: 5
        queue-capacity: 10
        keep-alive-duration: 20ms
        writable-stack-trace-enabled: true

call method

    @Bulkhead(name = "singleAnalysisThreadPoolBulkhead",type = Bulkhead.Type.THREADPOOL,fallbackMethod ="fallbackForThreadPoolBulkhead")
    public VueElementAdminResponse singleAnalysis(HxConsistencyAnalysisParam param) {
        try {
            Stopwatch stopwatch=Stopwatch.createStarted();
            VueElementAdminResponse vueElementAdminResponse=analysis(param);
            stopwatch.stop();
            logger.warn("cost_time:{}",stopwatch);
            return vueElementAdminResponse;
        }catch (RejectedExecutionException e){
            VueElementAdminResponse vueElementAdminResponse = new VueElementAdminResponse();
            vueElementAdminResponse.setCode(ResponseCodeEnum.THREAD_POOL_OF_CALL.getCode());
            vueElementAdminResponse.setMessage("thread pool is full");
            vueElementAdminResponse.setData(e.getMessage());
            return vueElementAdminResponse;
        } catch (Exception e) {
            VueElementAdminResponse vueElementAdminResponse = new VueElementAdminResponse();
            vueElementAdminResponse.setCode(ResponseCodeEnum.OTHER_SERVER_EXCEPTION.getCode());
            vueElementAdminResponse.setMessage("call exception");
            vueElementAdminResponse.setData(e);
            return vueElementAdminResponse;
        }
    }
   public VueElementAdminResponse rateLimiterFallback(HxConsistencyAnalysisParam param, Throwable throwable) {
        return VueElementAdminResponse.builder()
                .code(ResponseCodeEnum.REQUEST_FREQUENCY_OF_CALL.getCode())
                .message(ResponseCodeEnum.REQUEST_FREQUENCY_OF_CALL.getMessage())
                .data(param)
                .build();
    }
    public VueElementAdminResponse fallbackForThreadPoolBulkhead(HxConsistencyAnalysisParam param,Throwable throwable) {
        return VueElementAdminResponse.builder()
                .code(ResponseCodeEnum.THREAD_POOL_OF_CALL.getCode())
                .message(ResponseCodeEnum.THREAD_POOL_OF_CALL.getMessage())
                .data(param)
                .build();
    }
@RobWin
Copy link
Member

RobWin commented Jan 8, 2024

If you add implementation("io.micrometer:micrometer-registry-prometheus"), you can check the metrics of the prometheus endpoint.
See: https://resilience4j.readme.io/docs/micrometer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants