Hi I created a ticket to add option so you can throw exception again https://issues.apache.org/jira/browse/CAMEL-18507
demo.throwExceptionWhenHalfOpenOrOpenState=true On Wed, Sep 14, 2022 at 3:27 PM Claus Ibsen <claus.ib...@gmail.com> wrote: > Hi > > Okay so found the change > https://issues.apache.org/jira/browse/CAMEL-16173 > > When the CB goes into a half-open / open state then an exception is not > thrown as the CB is not failing, it just rejects calling the downstream. > You have state on exchange properties you can use to know if it was > rejected or not > > exchange.setProperty(ExchangePropertyKey.CIRCUIT_BREAKER_RESPONSE_SHORT_CIRCUITED, > true); > exchange.setProperty(ExchangePropertyKey.CIRCUIT_BREAKER_RESPONSE_REJECTED, > true); > > > > On Wed, Sep 14, 2022 at 1:59 PM Abhishek Rajendra Yadav > <abhishek.ya...@wu.com.invalid> wrote: > >> Hi, >> >> Please find the github repo below for the demo project which demonstrates >> the stated circuit breaker issue. >> >> https://github.com/abhi0402/camel-demo >> >> It uses spring boot 2.6.7 and Java 17 >> >> Endpoint exposed: http://localhost:9002/camel/v1/users >> >> In 3.4.2 camel version: >> >> Upon hitting the above endpoint 4 times(configured in >> demo.minimumNumberOfCalls property) the 5th time it throws an circuit >> breaker exception which is expected. >> >> In 3.18.2 camel version: >> >> Upon hitting the above endpoint 4 times(configured in >> demo.minimumNumberOfCalls property) the 5th time it doesn't throws any >> exception, just returns an empty response. >> >> The camel version can be changed in pom.xml under properties tag. >> >> Regards, >> Abhishek >> >> >> On 2022/09/13 12:56:35 Claus Ibsen wrote: >> > Hi >> > >> > Are you able to put together a sample Camel project that reproduces this >> > problem, and upload it to either github somewhere, or as a .zip file? >> > And you are welcome to create a JIRA ticket, where you can upload the >> .zip >> > file. >> > >> > That is easier for us to use to look into this. >> > And you are surely welcome to dive into the code and see if you can find >> > the problem, or link back to code changes (JIRAs) that can help clarify >> > this. >> > >> > >> > >> > >> > >> > >> > On Tue, Sep 13, 2022 at 12:28 PM Abhishek Rajendra Yadav >> > <ab...@wu.com.invalid> wrote: >> > >> > > Hi, >> > > >> > > While upgrading Camel from our current verion (3.4.2) to the latest >> > > version (3.18.2) we are running into an issue where the resilience4j >> > > circuit breaker is not working as expected. After the circuit is OPEN >> it >> > > should throw an exception(CallNotPermittedException) same as 3.4.2 but >> > > instead the execution continues without throwing any exception. >> > > >> > > Upon further debugging, we could see the difference in execution logs >> > > which are attached below. >> > > >> > > logs from 3.4.2 camel version - >> > > >> > > 2022-09-13T10:28:59,162 DEBUG [http-nio-8086-exec-8] >> o.a.c.s.CamelLogger: >> > > Request is routed to service2 >> > > 2022-09-13T10:28:59,163 DEBUG [ForkJoinPool.commonPool-worker-1] >> > > i.g.r.c.i.CircuitBreakerStateMachine: No Consumers: Event >> NOT_PERMITTED not >> > > published >> > > 2022-09-13T10:28:59,163 DEBUG [http-nio-8086-exec-8] >> > > o.a.c.p.PipelineHelper: Message exchange has failed: so breaking out >> of >> > > pipeline for exchange: Exchange[ID-WKSWUPUN2455-1663045118166-0-5] >> > > Exception: >> io.github.resilience4j.circuitbreaker.CallNotPermittedException: >> > > CircuitBreaker 'circuitBreaker3' is OPEN and does not permit further >> calls >> > > 2022-09-13T10:28:59,163 DEBUG [http-nio-8086-exec-8] >> o.a.c.s.CamelLogger: >> > > Failed delivery for (MessageId: ID-WKSWUPUN2455-1663045118166-0-5 on >> > > ExchangeId: ID-WKSWUPUN2455-1663045118166-0-5). On delivery attempt: 0 >> > > caught: >> io.github.resilience4j.circuitbreaker.CallNotPermittedException: >> > > CircuitBreaker 'circuitBreaker3' is OPEN and does not permit further >> calls >> > > 2022-09-13T10:28:59,163 ERROR [http-nio-8086-exec-8] >> > > c.w.c.i.o.c.p.CaseExceptionProcessor: >> > > io.github.resilience4j.circuitbreaker.CallNotPermittedException: >> > > CircuitBreaker 'circuitBreaker3' is OPEN and does not permit further >> calls >> > > at >> > > >> io.github.resilience4j.circuitbreaker.CallNotPermittedException.createCallNotPermittedException(CallNotPermittedException.java:48) >> > > at >> > > >> io.github.resilience4j.circuitbreaker.internal.CircuitBreakerStateMachine$OpenState.acquirePermission(CircuitBreakerStateMachine.java:689) >> > > at >> > > >> io.github.resilience4j.circuitbreaker.internal.CircuitBreakerStateMachine.acquirePermission(CircuitBreakerStateMachine.java:206) >> > > at >> > > >> io.github.resilience4j.circuitbreaker.CircuitBreaker.lambda$decorateCallable$3(CircuitBreaker.java:168) >> > > at >> > > >> org.apache.camel.component.resilience4j.ResilienceProcessor$CircuitBreakerTimeoutTask.get(ResilienceProcessor.java:517) >> > > at >> > > >> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) >> > > at >> > > >> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) >> > > at >> > > >> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) >> > > at >> > > >> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) >> > > at >> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) >> > > at >> > > >> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) >> > > at >> > > >> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) >> > > >> > > 2022-09-13T10:28:59,164 DEBUG [http-nio-8086-exec-8] >> > > o.a.c.p.PipelineHelper: Message exchange has failed: so breaking out >> of >> > > pipeline for exchange: Exchange[ID-WKSWUPUN2455-1663045118166-0-5] >> Handled >> > > by the error handler. >> > > 2022-09-13T10:28:59,166 DEBUG [http-nio-8086-exec-8] >> > > o.a.c.h.c.DefaultHttpBinding: Streaming response in chunked mode with >> > > buffer size 8192 >> > > 2022-09-13T10:29:48,360 DEBUG [CircuitBreakerAutoTransitionThread] >> > > i.g.r.c.i.CircuitBreakerStateMachine: No Consumers: Event >> STATE_TRANSITION >> > > not published >> > > >> > > logs from 3.18.2 camel version - >> > > >> > > 2022-09-13T10:49:10,036 DEBUG [http-nio-8086-exec-7] >> o.a.c.s.CamelLogger: >> > > Request is routed to service2 >> > > 2022-09-13T10:49:10,037 DEBUG [http-nio-8086-exec-7] >> > > i.g.r.c.i.CircuitBreakerStateMachine: No Consumers: Event >> NOT_PERMITTED not >> > > published >> > > 2022-09-13T10:49:10,037 INFO [http-nio-8086-exec-7] >> o.a.c.s.CamelLogger: >> > > Message sent successfully >> > > 2022-09-13T10:49:10,038 DEBUG [http-nio-8086-exec-7] >> > > o.a.c.p.FilterProcessor: Filter matches: true for exchange: >> > > Exchange[4A5CC43440BCF38-0000000000000002] >> > > 2022-09-13T10:49:10,038 DEBUG [http-nio-8086-exec-7] >> > > o.a.c.h.c.DefaultHttpBinding: Streaming response in chunked mode with >> > > buffer size 8192 >> > > >> > > Route Code snippet - >> > > >> > > from("direct:route24") >> > > .streamCaching() >> > > .log(LoggingLevel.DEBUG, "Request is routed to service2") >> > > .process(requestProcessor) >> > > .marshal().json(JsonLibrary.Jackson) >> > > .circuitBreaker() >> > > .resilience4jConfiguration(resilience4jConfigurationDefinition) >> > > .to("{{url}}") >> > > .end() >> > > .log(LoggingLevel.INFO, "Message sent successfully"); >> > > >> > > >> > > resilience4jConfiguration is as follows: >> > > >> > > #circuit breaker >> > > failureRateThreshold=50 >> > > automaticTransitionFromOpenToHalfOpenEnabled=true >> > > waitDurationInOpenState=60 >> > > minimumNumberOfCalls=4 >> > > permittedNumberOfCallsInHalfOpenState=6 >> > > slidingWindowType=COUNT_BASED >> > > slidingWindowSize=100 >> > > timeoutEnabled=true >> > > timeoutDuration=30000 >> > > slowCallRateThreshold=100 >> > > slowCallDurationThreshold=60 >> > > >> > > How do we get the same behavior as previous(3.4.2) of circuit breaker >> in >> > > version 3.18.2 of camel? >> > > >> > > Thank you, >> > > Abhishek >> > > >> > > >> > > >> > > The information transmitted, including any content in this >> communication >> > > is confidential, is intended only for the use of the intended >> recipient and >> > > is the property of the Western Union Company or its affiliates and >> > > subsidiaries. If you are not the intended recipient, you are hereby >> > > notified that any use of the information contained in or transmitted >> with >> > > the communication or dissemination, distribution, or copying of this >> > > communication is strictly prohibited. If you have received this >> > > communication in error, please notify the Western Union sender >> immediately >> > > by replying to this message and delete the original message >> > > >> > >> > >> > -- >> > Claus Ibsen >> > ----------------- >> > http://davsclaus.com @davsclaus >> > Camel in Action 2: https://www.manning.com/ibsen2 >> > >> The information transmitted, including any content in this communication >> is confidential, is intended only for the use of the intended recipient and >> is the property of the Western Union Company or its affiliates and >> subsidiaries. If you are not the intended recipient, you are hereby >> notified that any use of the information contained in or transmitted with >> the communication or dissemination, distribution, or copying of this >> communication is strictly prohibited. If you have received this >> communication in error, please notify the Western Union sender immediately >> by replying to this message and delete the original message >> > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 > -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2