R - public interface HystrixExecutable<R> extends HystrixInvokable<R>
HystrixCommand and HystrixCollapser) so client code can treat them the same and combine in typed collections if desired.| Modifier and Type | Method and Description |
|---|---|
R |
execute()
Used for synchronous execution of command.
|
rx.Observable<R> |
observe()
Used for asynchronous execution of command with a callback by subscribing to the
Observable. |
java.util.concurrent.Future<R> |
queue()
Used for asynchronous execution of command.
|
R execute()
HystrixCommand executionHystrixRuntimeException - if an error occurs and a fallback cannot be retrievedHystrixBadRequestException - if the HystrixCommand instance considers request arguments to be invalid and needs to throw an error that does not represent a system failurejava.util.concurrent.Future<R> queue()
This will queue up the command on the thread pool and return an Future to get the result once it completes.
NOTE: If configured to not run in a separate thread, this will have the same effect as execute() and will block.
We don't throw an exception in that case but just flip to synchronous execution so code doesn't need to change in order to switch a circuit from running a separate thread to the calling thread.
Future<R> Result of HystrixCommand executionHystrixRuntimeException - if an error occurs and a fallback cannot be retrievedHystrixBadRequestException - if the HystrixCommand instance considers request arguments to be invalid and needs to throw an error that does not represent a system failurerx.Observable<R> observe()
Observable.
This eagerly starts execution of the command the same as queue() and execute().
A lazy Observable can be obtained from AbstractCommand.toObservable() or HystrixCollapser.toObservable().
Callback Scheduling
HystrixCommandProperties.ExecutionIsolationStrategy.THREAD this defaults to using Schedulers.computation() for callbacks.HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE this defaults to using Schedulers.immediate() for callbacks.See https://github.com/Netflix/RxJava/wiki for more information.
Observable<R> that executes and calls back with the result of the command execution or a fallback if the command fails for any reason.HystrixRuntimeException - if a fallback does not exist
Observer#onError if a failure occursHystrixBadRequestException - via Observer#onError if invalid arguments or state were used representing a user failure, not a system failurejava.lang.IllegalStateException - if invoked more than once