This is the first release candidate of 1.4.0 that includes HystrixObservableCommand
(Source) that supports bulkheading asynchronous, non-blocking sources.
NOTE: This code is NOT considered production worthy yet, hence the "Release Candidate" status.
It has run for 1 day on a single machine taking production traffic at Netflix. This is sufficient for us to proceed to a release candidate for official canary testing, but we intend to test for a week or two before doing a final release.
Here is a very basic example using Java 8 to make an HTTP call via Netty and receives a stream of chunks back:
public static void main(String args[]) {
HystrixObservableCommand<String> command = bulkheadedNetworkRequest("www.google.com");
command.toObservable()
// using BlockingObservable.forEach for demo simplicity
.toBlockingObservable().forEach(d -> System.out.println(d));
System.out.println("Time: " + command.getExecutionTimeInMilliseconds() + " Events: " + command.getExecutionEvents());
}
public static HystrixObservableCommand<String> bulkheadedNetworkRequest(final String host) {
return new HystrixObservableCommand<String>(HystrixCommandGroupKey.Factory.asKey("http")) {
@Override
protected Observable<String> run() {
return directNetworkRequest(host);
}
@Override
protected Observable<String> getFallback() {
return Observable.just("Error 500");
}
};
}
public static Observable<String> directNetworkRequest(String host) {
return RxNetty.createHttpClient(host, 80)
.submit(HttpClientRequest.createGet("/"))
.flatMap(response -> response.getContent())
.map(data -> data.toString(Charset.defaultCharset()));
}
- Pull 218 Hystrix 1.4 - Async/Non-Blocking
- Pull 217 Javanica: Added support for "Reactive Execution" and "Error Propagation"
- Pull 219 Restore HystrixContext* Constructors without ConcurrencyStrategy
Artifacts: Maven Central