The working of Hystrix is as follows:
- Creating an instance of command: We need to create an instance of either HystrixCommand or HystrixObservableCommand to present the request that we are making to the dependency. These instances will be working as a wrapper around the dependency that we are requesting.
- The instance of HystrixCommand is used to wrap a request that will execute the functionality or service over the network with fault and latency tolerance with a blocking call. However, the observe() method returns a non-blocking Observable. We prefer the instance whenever a single response is expected from the dependency. The following lines of code demonstrate the creation of an instance of HystrixCommand: