Using Hystrix

In order to learn Hystrix behavior in practice, we are going to extend customer-gateway service so that it uses Hystrix for its invocations. Later, we are going to make one of our services artificially unresponsive and see how Hystrix behaves. Let's start.

Examples reference: chapter11/customer-gateway-hystrix.

Firstly, we are going to add Hystrix dependency to the pom.xml:

(...)<dependency>    <groupId>com.netflix.hystrix</groupId>    <artifactId>hystrix-core</artifactId>    <version>${version.hystrix}</version></dependency>(...)

The circuit breaker command is implemented by extending the com.netflix.hystrix.HystrixCommand class. Let's take a look at its usage at the concrete example of our PricingProxy:

(...)@ApplicationScopedpublic ...

Get Hands-On Cloud Development with WildFly now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.