This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git
The following commit(s) were added to refs/heads/main by this push: new c26c1ee Add a little circuit breaker example c26c1ee is described below commit c26c1eea12bbedad9751cc57c73ae8c2cc07fc79 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Nov 1 11:52:57 2022 +0100 Add a little circuit breaker example --- jbang/circuit-breaker/README.adoc | 68 +++++++++++++++++++++++++++++++++++++++ jbang/circuit-breaker/mycb.yaml | 26 +++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/jbang/circuit-breaker/README.adoc b/jbang/circuit-breaker/README.adoc new file mode 100644 index 0000000..4399b67 --- /dev/null +++ b/jbang/circuit-breaker/README.adoc @@ -0,0 +1,68 @@ +== Circuit Breaker + +This example shows how Camel JBang can use ciruit breaker EIP. + +=== Install JBang + +First install JBang according to https://www.jbang.dev + +When JBang is installed then you should be able to run from a shell: + +[source,sh] +---- +$ jbang --version +---- + +This will output the version of JBang. + +To run this example you can either install Camel on JBang via: + +[source,sh] +---- +$ jbang app install camel@apache/camel +---- + +Which allows to run CamelJBang with `camel` as shown below. + +=== How to run + +Then you can run this example using: + +[source,sh] +---- +$ camel run * +---- + +Or run with JBang using the longer command line (without installing camel as app in JBang): + +[source,sh] +---- +$ jbang camel@apache/camel run * +---- + +While the Camel integration is running, then from another terminal type: + +[source,sh] +---- +$ camel get circuit-breaker +---- + +Which then output the state of the circuit breaker. You can run this command with `watch` and see +how the state of the circuit breaker changes from closed to open due to many failures. + +[source,sh] +---- +$ watch camel get circuit-breaker +---- + + + +=== Help and contributions + +If you hit any problem using Camel or have some feedback, then please +https://camel.apache.org/community/support/[let us know]. + +We also love contributors, so +https://camel.apache.org/community/contributing/[get involved] :-) + +The Camel riders! diff --git a/jbang/circuit-breaker/mycb.yaml b/jbang/circuit-breaker/mycb.yaml new file mode 100644 index 0000000..0dc1766 --- /dev/null +++ b/jbang/circuit-breaker/mycb.yaml @@ -0,0 +1,26 @@ +- route: + from: + uri: timer:yaml + steps: + - setBody: + expression: + constant: + expression: Hello Camel from yaml + - circuitBreaker: + steps: + - filter: + expression: + simple: + expression: ${random(10)} > 2 + steps: + - throwException: + message: Forced error + exceptionType: java.lang.IllegalArgumentException + resilience4jConfiguration: + minimumNumberOfCalls: 10 + failureRateThreshold: 50 + waitDurationInOpenState: 20 + - log: + message: "${body} (CircuitBreaker is open: ${exchangeProperty.CamelCircuitBreakerResponseShortCircuited})" + parameters: + period: '1000'