This example shows how to use Camel with Hystrix EIP as circuit breaker in Camel routes
The example includes three sub maven modules that implement
-
client
-
service1
-
service2
Where client → service1 client → service2 (fallback)
Service1 is configured in the
src/main/java/sample/camel/Service1Application.java
source code.
Service2 is configured in the
src/main/resources/application.properties
properties file.
Then using three different shells and run service1 and service2 before the client.
$ cd service1
$ mvn compile spring-boot:run
When service1 is ready then start service2
$ cd service2
$ mvn compile camel:run
And then start the client that calls service1 every second.
$ cd client
$ mvn compile spring-boot:run
You can then stop service1 and see that the client should fallback to call service2 in the Hystrix EIP circuit breaker. And then start service 1 again and see the Hystrix EIP go back to normal.
You should be able to visualize the state of the Hystrix Circuit Breaker in the Hystrix Web Console.
You can find instructions at Hystrix how to build and run the web console: https://github.com/Netflix/Hystrix/wiki/Dashboard
For example using gradle, you can then access the web console locally
at: http://localhost:7979/hystrix-dashboard
.
The stream is accessible from the client at:
http://localhost:8080/hystrix.stream
which you can add as stream to
the web console and then you should see the circuit breakers. In the
screenshot below, we have just stopped service1, so the Hystrix EIP
will execute the fallback via network, which is calling service2
instead. If you start service 1 again then the Hystrix EIP should go
back to green again.
If you hit any problem using Camel or have some feedback, then please let us know.
We also love contributors, so get involved :-)
The Camel riders!