Skip to content

Instantly share code, notes, and snippets.

@ianha
Created January 17, 2017 21:48
Show Gist options
  • Save ianha/12c7ac8fb116fccf19e7c6ebb89be88a to your computer and use it in GitHub Desktop.
Save ianha/12c7ac8fb116fccf19e7c6ebb89be88a to your computer and use it in GitHub Desktop.
runHystrixCommand(
COMMAND_GROUP,
COMMAND_KEY,
TIMEOUT_IN_MILLIS,
new Callable<Observable<HttpResponse>>() {
@Override
public Observable<HttpResponse> call() throws Exception {
return Observable.just(request.execute().returnResponse());
}
}
).subscribe(new Action1<HttpResponse>() {
@Override
public void call(final HttpResponse httpResponse) {
statusCode.set(httpResponse.getStatusLine().getStatusCode());
}
}, new Action1<Throwable>() {
@Override
public void call(final Throwable throwable) {
logger.error(String.format("Error calling webhook %s", webHook), throwable);
statusCode.set(HttpStatus.INTERNAL_SERVER_ERROR.value());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment