lundi 4 avril 2022

Resilience4j Circuit breaker design patter implementation

Getting the below error when trying to bring up the spring boot application with circuit breaker implementation using resilience4j

2022-03-30T14:59:25-04:00 DEBUG 57531 --- [main] r.boo.dia.LoggingFailureAnalysisReporter: Application failed to start due to an exception org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 2 errors Field error in object 'resilience4j.circuitbreaker' on field 'configs[shared].slowCallDurationThreshold': rejected value [2s]; codes [typeMismatch.resilience4j.circuitbreaker.configs[shared].slowCallDurationThreshold,typeMismatch.resilience4j.circuitbreaker.configs.slowCallDurationThreshold,typeMismatch.configs[shared].slowCallDurationThreshold,typeMismatch.configs.slowCallDurationThreshold,typeMismatch.slowCallDurationThreshold,typeMismatch.java.time.Duration,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [resilience4j.circuitbreaker.configs[shared].slowCallDurationThreshold,configs[shared].slowCallDurationThreshold]; arguments []; default message [configs[shared].slowCallDurationThreshold]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.time.Duration' for property 'configs[shared].slowCallDurationThreshold'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.time.Duration' for property 'slowCallDurationThreshold': no matching editors or conversion strategy found] Field error in object 'resilience4j.circuitbreaker' on field 'configs[shared].waitDurationInOpenState': rejected value [10s]; codes [typeMismatch.resilience4j.circuitbreaker.configs[shared].waitDurationInOpenState,typeMismatch.resilience4j.circuitbreaker.configs.waitDurationInOpenState,typeMismatch.configs[shared].waitDurationInOpenState,typeMismatch.configs.waitDurationInOpenState,typeMismatch.waitDurationInOpenState,typeMismatch.java.time.Duration,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [resilience4j.circuitbreaker.configs[shared].waitDurationInOpenState,configs[shared].waitDurationInOpenState]; arguments []; default message [configs[shared].waitDurationInOpenState]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.time.Duration' for property 'configs[shared].waitDurationInOpenState'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.time.Duration' for property 'waitDurationInOpenState': no matching editors or conversion strategy found]  at org.springframework.boot.bind.PropertiesConfigurationFactory.checkForBindingErrors(PropertiesConfigurationFactory.java:359) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]   at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:276) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:240) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:330) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]     at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:292) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
        

Using resilience4j version 1.3

My application.properties

#CircuitBreaker Resilience4j Design Config

Resiliece4j Configuration

resilience4j.circuitbreaker.configs.shared.register-health-indicator=trueresilience4j.circuitbreaker.configs.shared.sliding-window-type=count_basedresilience4j.circuitbreaker.configs.shared.sliding-window-size=5resilience4j.circuitbreaker.configs.shared.failure-rate-threshold=40resilience4j.circuitbreaker.configs.shared.slow-call-rate-threshold=40resilience4j.circuitbreaker.configs.shared.permitted-number-of-calls-in-half-open-state=1resilience4j.circuitbreaker.configs.shared.max-wait-duration-in-half-open-state=10sresilience4j.circuitbreaker.configs.shared.wait-duration-in-open-state=10sresilience4j.circuitbreaker.configs.shared.slow-call-duration-threshold=2sresilience4j.circuitbreaker.configs.shared.writable-stack-trace-enabled=trueresilience4j.circuitbreaker.configs.shared.automatic-transition-from-open-to-half-open-enabled=true

resilience4j.circuitbreaker.instances.cradlepoint-api.base-config=shared

Using circuitbreaker annotation above the method in service class where the API call happens to a 3rd party application.

I am trying to bring up the server for my spring boot app which is failing with the above error. So I am expecting the server to start without any issues so that I can check the health of the citcuitbreaker using actuator api call

Aucun commentaire:

Enregistrer un commentaire