Similar to the HystrixCommand implementation, we can also create an extension of HystrixObservableCommand to support reactive programming, as shown here:
public class DemoHystrixObservableCommand extends HystrixObservableCommand<String> { private String user; public DemoHystrixObservableCommand(String user) { super(HystrixCommandGroupKey.Factory.asKey("packtGroup")); this.user=user; } @Override protected Observable<String> construct() { // TODO Auto-generated method stub return Observable.just("Welcome to Hystrix, "+user); } }
Here, the construct() method has Observable as the return type that facilitates reactive programming.
We can now test HystrixObservableCommand by creating the test case, as shown in the following...