spring-cloud / spring-cloud-circuitbreaker

Spring Cloud Circuit Breaker API and Implementations
Apache License 2.0
336 stars 110 forks source link

ReactiveResilience4j event consumer not working #158

Closed p4w4n closed 1 year ago

p4w4n commented 1 year ago

Hi,

I am using Spring Cloud Gateway and has created a below bean.

    @Bean
    @RefreshScope
    public Customizer<ReactiveResilience4JCircuitBreakerFactory> hgwCircuitBreaker(){
        return factory -> {
            routeCircuitBreakers.forEach((id,name) ->{

                factory.configure(builder -> builder.circuitBreakerConfig(CircuitBreakerConfig.ofDefaults()).build()
                                .setCircuitBreakerConfig(CircuitBreakerConfig.custom().minimumNumberOfCalls(10).failureRateThreshold(20).build())
                        , id);
                if(name.getSelectAttribute() != ""){
                    HashMap<String, CBFilterCfg> cbFilters = name.getCbFilters();
                    if(!cbFilters.isEmpty()) {
                        cbFilters.forEach((filterId, cbFilterCfg) -> {
                            factory.configure(builder -> builder.circuitBreakerConfig(CircuitBreakerConfig.ofDefaults()).build()
                                            .setCircuitBreakerConfig(CircuitBreakerConfig.custom().minimumNumberOfCalls(1).failureRateThreshold(1).build())
                                    , id + "-" + cbFilterCfg.getAttributeValue());

                        });
                    }
                }

            });

            Customizer.once(circuitBreaker -> {
                circuitBreaker.getEventPublisher()
                        .onEvent(event -> LOGGER.info(Logger.EVENT_SUCCESS, event.getCircuitBreakerName()+" : "+event));
            }, CircuitBreaker::getName);

        };
    }

But I am not seeing any log related to any event in Circuit Breaker. Do I need to create a consumer somewhere so that it can start logging the events?

Thanks!!!

ryanjbaxter commented 1 year ago

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

spring-cloud-issues commented 1 year ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues commented 1 year ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.