public abstract class HystrixCommandExecutionHook
extends java.lang.Object
HystrixCommand
and HystrixObservableCommand
execution with default no-op implementations.
See HystrixPlugins
or the Hystrix GitHub Wiki for information on configuring plugins: https://github.com/Netflix/Hystrix/wiki/Plugins.
Note on thread-safety and performance
A single implementation of this class will be used globally so methods on this class will be invoked concurrently from multiple threads so all functionality must be thread-safe.
Methods are also invoked synchronously and will add to execution time of the commands so all behavior should be fast. If anything time-consuming is to be done it should be spawned asynchronously onto separate worker threads.
Constructor and Description |
---|
HystrixCommandExecutionHook() |
Modifier and Type | Method and Description |
---|---|
<T> void |
onCacheHit(HystrixInvokable<T> commandInstance)
Invoked when the command response is found in the
HystrixRequestCache . |
<T> T |
onComplete(HystrixCommand<T> commandInstance,
T response)
Deprecated.
|
<T> T |
onComplete(HystrixInvokable<T> commandInstance,
T response)
Deprecated.
|
<T> T |
onEmit(HystrixInvokable<T> commandInstance,
T value)
Invoked when
HystrixInvokable emits a value. |
<T> java.lang.Exception |
onError(HystrixCommand<T> commandInstance,
HystrixRuntimeException.FailureType failureType,
java.lang.Exception e)
Deprecated.
|
<T> java.lang.Exception |
onError(HystrixInvokable<T> commandInstance,
HystrixRuntimeException.FailureType failureType,
java.lang.Exception e)
Invoked when
HystrixInvokable fails with an Exception. |
<T> T |
onExecutionEmit(HystrixInvokable<T> commandInstance,
T value)
Invoked when the user-defined execution method in
HystrixInvokable emits a value. |
<T> java.lang.Exception |
onExecutionError(HystrixInvokable<T> commandInstance,
java.lang.Exception e)
Invoked when the user-defined execution method in
HystrixInvokable fails with an Exception. |
<T> void |
onExecutionStart(HystrixInvokable<T> commandInstance)
Invoked when the user-defined execution method in
HystrixInvokable starts. |
<T> void |
onExecutionSuccess(HystrixInvokable<T> commandInstance)
Invoked when the user-defined execution method in
HystrixInvokable completes successfully. |
<T> T |
onFallbackEmit(HystrixInvokable<T> commandInstance,
T value)
Invoked when the fallback method in
HystrixInvokable emits a value. |
<T> java.lang.Exception |
onFallbackError(HystrixCommand<T> commandInstance,
java.lang.Exception e)
Deprecated.
|
<T> java.lang.Exception |
onFallbackError(HystrixInvokable<T> commandInstance,
java.lang.Exception e)
Invoked when the fallback method in
HystrixInvokable fails with an Exception. |
<T> void |
onFallbackStart(HystrixCommand<T> commandInstance)
Deprecated.
|
<T> void |
onFallbackStart(HystrixInvokable<T> commandInstance)
Invoked when the fallback method in
HystrixInvokable starts. |
<T> T |
onFallbackSuccess(HystrixCommand<T> commandInstance,
T fallbackResponse)
Deprecated.
|
<T> void |
onFallbackSuccess(HystrixInvokable<T> commandInstance)
Invoked when the user-defined execution method in
HystrixInvokable completes successfully. |
<T> T |
onFallbackSuccess(HystrixInvokable<T> commandInstance,
T fallbackResponse)
Deprecated.
|
<T> java.lang.Exception |
onRunError(HystrixCommand<T> commandInstance,
java.lang.Exception e)
Deprecated.
|
<T> java.lang.Exception |
onRunError(HystrixInvokable<T> commandInstance,
java.lang.Exception e)
Deprecated.
|
<T> void |
onRunStart(HystrixCommand<T> commandInstance)
Deprecated.
|
<T> void |
onRunStart(HystrixInvokable<T> commandInstance)
Deprecated.
|
<T> T |
onRunSuccess(HystrixCommand<T> commandInstance,
T response)
Deprecated.
|
<T> T |
onRunSuccess(HystrixInvokable<T> commandInstance,
T response)
Deprecated.
|
<T> void |
onStart(HystrixCommand<T> commandInstance)
Deprecated.
|
<T> void |
onStart(HystrixInvokable<T> commandInstance)
Invoked before
HystrixInvokable begins executing. |
<T> void |
onSuccess(HystrixInvokable<T> commandInstance)
Invoked when
HystrixInvokable finishes a successful execution. |
<T> void |
onThreadComplete(HystrixCommand<T> commandInstance)
Deprecated.
|
<T> void |
onThreadComplete(HystrixInvokable<T> commandInstance)
Invoked at completion of thread execution when
HystrixCommand is executed using HystrixCommandProperties.ExecutionIsolationStrategy.THREAD . |
<T> void |
onThreadStart(HystrixCommand<T> commandInstance)
Deprecated.
|
<T> void |
onThreadStart(HystrixInvokable<T> commandInstance)
Invoked at start of thread execution when
HystrixCommand is executed using HystrixCommandProperties.ExecutionIsolationStrategy.THREAD . |
public <T> void onStart(HystrixInvokable<T> commandInstance)
HystrixInvokable
begins executing.commandInstance
- The executing HystrixInvokable instance.public <T> T onEmit(HystrixInvokable<T> commandInstance, T value)
HystrixInvokable
emits a value.commandInstance
- The executing HystrixInvokable instance.value
- value emittedpublic <T> java.lang.Exception onError(HystrixInvokable<T> commandInstance, HystrixRuntimeException.FailureType failureType, java.lang.Exception e)
HystrixInvokable
fails with an Exception.commandInstance
- The executing HystrixInvokable instance.failureType
- HystrixRuntimeException.FailureType
enum representing which type of errore
- exception objectpublic <T> void onSuccess(HystrixInvokable<T> commandInstance)
HystrixInvokable
finishes a successful execution.commandInstance
- The executing HystrixInvokable instance.public <T> void onThreadStart(HystrixInvokable<T> commandInstance)
HystrixCommand
is executed using HystrixCommandProperties.ExecutionIsolationStrategy.THREAD
.commandInstance
- The executing HystrixCommand instance.public <T> void onThreadComplete(HystrixInvokable<T> commandInstance)
HystrixCommand
is executed using HystrixCommandProperties.ExecutionIsolationStrategy.THREAD
.
This will get invoked whenever the Hystrix thread is done executing, regardless of whether the thread finished
naturally, or was unsubscribed externallycommandInstance
- The executing HystrixCommand instance.public <T> void onExecutionStart(HystrixInvokable<T> commandInstance)
HystrixInvokable
starts.commandInstance
- The executing HystrixInvokable instance.public <T> T onExecutionEmit(HystrixInvokable<T> commandInstance, T value)
HystrixInvokable
emits a value.commandInstance
- The executing HystrixInvokable instance.value
- value emittedpublic <T> java.lang.Exception onExecutionError(HystrixInvokable<T> commandInstance, java.lang.Exception e)
HystrixInvokable
fails with an Exception.commandInstance
- The executing HystrixInvokable instance.e
- exception objectpublic <T> void onExecutionSuccess(HystrixInvokable<T> commandInstance)
HystrixInvokable
completes successfully.commandInstance
- The executing HystrixInvokable instance.public <T> void onFallbackStart(HystrixInvokable<T> commandInstance)
HystrixInvokable
starts.commandInstance
- The executing HystrixInvokable instance.public <T> T onFallbackEmit(HystrixInvokable<T> commandInstance, T value)
HystrixInvokable
emits a value.commandInstance
- The executing HystrixInvokable instance.value
- value emittedpublic <T> java.lang.Exception onFallbackError(HystrixInvokable<T> commandInstance, java.lang.Exception e)
HystrixInvokable
fails with an Exception.commandInstance
- The executing HystrixInvokable instance.e
- exception objectpublic <T> void onFallbackSuccess(HystrixInvokable<T> commandInstance)
HystrixInvokable
completes successfully.commandInstance
- The executing HystrixInvokable instance.public <T> void onCacheHit(HystrixInvokable<T> commandInstance)
HystrixRequestCache
.commandInstance
- The executing HystrixCommand@Deprecated public <T> void onRunStart(HystrixCommand<T> commandInstance)
onExecutionStart(com.netflix.hystrix.HystrixInvokable<T>)
.
Invoked before HystrixCommand.run()
is about to be executed.commandInstance
- The executing HystrixCommand instance.@Deprecated public <T> void onRunStart(HystrixInvokable<T> commandInstance)
onExecutionStart(com.netflix.hystrix.HystrixInvokable<T>)
.
Invoked before HystrixCommand.run()
is about to be executed.commandInstance
- The executing HystrixCommand instance.@Deprecated public <T> T onRunSuccess(HystrixCommand<T> commandInstance, T response)
onExecutionEmit(com.netflix.hystrix.HystrixInvokable<T>, T)
if you want to add a hook for each value emitted by the command
or to onExecutionSuccess(com.netflix.hystrix.HystrixInvokable<T>)
if you want to add a hook when the command successfully executes
Invoked after successful execution of HystrixCommand.run()
with response value.
In a HystrixCommand
using HystrixCommandProperties.ExecutionIsolationStrategy.THREAD
, this will get invoked if the Hystrix thread
successfully runs, regardless of whether the calling thread encountered a timeout.commandInstance
- The executing HystrixCommand instance.response
- from HystrixCommand.run()
@Deprecated public <T> T onRunSuccess(HystrixInvokable<T> commandInstance, T response)
onExecutionEmit(com.netflix.hystrix.HystrixInvokable<T>, T)
if you want to add a hook for each value emitted by the command
or to onExecutionSuccess(com.netflix.hystrix.HystrixInvokable<T>)
if you want to add a hook when the command successfully executes
Invoked after successful execution of HystrixCommand.run()
with response value.
In a HystrixCommand
using HystrixCommandProperties.ExecutionIsolationStrategy.THREAD
, this will get invoked if the Hystrix thread
successfully runs, regardless of whether the calling thread encountered a timeout.commandInstance
- The executing HystrixCommand instance.response
- from HystrixCommand.run()
@Deprecated public <T> java.lang.Exception onRunError(HystrixCommand<T> commandInstance, java.lang.Exception e)
onExecutionError(com.netflix.hystrix.HystrixInvokable<T>, java.lang.Exception)
Invoked after failed execution of HystrixCommand.run()
with thrown Exception.commandInstance
- The executing HystrixCommand instance.e
- Exception thrown by HystrixCommand.run()
@Deprecated public <T> java.lang.Exception onRunError(HystrixInvokable<T> commandInstance, java.lang.Exception e)
onExecutionError(com.netflix.hystrix.HystrixInvokable<T>, java.lang.Exception)
Invoked after failed execution of HystrixCommand.run()
with thrown Exception.commandInstance
- The executing HystrixCommand instance.e
- Exception thrown by HystrixCommand.run()
@Deprecated public <T> void onFallbackStart(HystrixCommand<T> commandInstance)
onFallbackStart(com.netflix.hystrix.HystrixInvokable<T>)
Invoked before HystrixCommand.getFallback()
is about to be executed.commandInstance
- The executing HystrixCommand instance.@Deprecated public <T> T onFallbackSuccess(HystrixCommand<T> commandInstance, T fallbackResponse)
onFallbackEmit(com.netflix.hystrix.HystrixInvokable<T>, T)
if you want to write a hook that handles each emitted fallback value
or to onFallbackSuccess(com.netflix.hystrix.HystrixInvokable<T>)
if you want to write a hook that handles success of the fallback method
Invoked after successful execution of HystrixCommand.getFallback()
with response value.commandInstance
- The executing HystrixCommand instance.fallbackResponse
- from HystrixCommand.getFallback()
@Deprecated public <T> T onFallbackSuccess(HystrixInvokable<T> commandInstance, T fallbackResponse)
onFallbackEmit(com.netflix.hystrix.HystrixInvokable<T>, T)
if you want to write a hook that handles each emitted fallback value
or to onFallbackSuccess(com.netflix.hystrix.HystrixInvokable<T>)
if you want to write a hook that handles success of the fallback method
Invoked after successful execution of HystrixCommand.getFallback()
with response value.commandInstance
- The executing HystrixCommand instance.fallbackResponse
- from HystrixCommand.getFallback()
@Deprecated public <T> java.lang.Exception onFallbackError(HystrixCommand<T> commandInstance, java.lang.Exception e)
onFallbackError(com.netflix.hystrix.HystrixInvokable<T>, java.lang.Exception)
.
Invoked after failed execution of HystrixCommand.getFallback()
with thrown exception.commandInstance
- The executing HystrixCommand instance.e
- Exception thrown by HystrixCommand.getFallback()
@Deprecated public <T> void onStart(HystrixCommand<T> commandInstance)
onStart(com.netflix.hystrix.HystrixInvokable<T>)
.
Invoked before HystrixCommand
executes.commandInstance
- The executing HystrixCommand instance.@Deprecated public <T> T onComplete(HystrixCommand<T> commandInstance, T response)
onEmit(com.netflix.hystrix.HystrixInvokable<T>, T)
if you want to write a hook that handles each emitted command value
or to onSuccess(com.netflix.hystrix.HystrixInvokable<T>)
if you want to write a hook that handles success of the command
Invoked after completion of HystrixCommand
execution that results in a response.
The response can come either from HystrixCommand.run()
or HystrixCommand.getFallback()
.
commandInstance
- The executing HystrixCommand instance.response
- from HystrixCommand.run()
or HystrixCommand.getFallback()
.@Deprecated public <T> T onComplete(HystrixInvokable<T> commandInstance, T response)
onEmit(com.netflix.hystrix.HystrixInvokable<T>, T)
if you want to write a hook that handles each emitted command value
or to onSuccess(com.netflix.hystrix.HystrixInvokable<T>)
if you want to write a hook that handles success of the command
Invoked after completion of HystrixCommand
execution that results in a response.
The response can come either from HystrixCommand.run()
or HystrixCommand.getFallback()
.
commandInstance
- The executing HystrixCommand instance.response
- from HystrixCommand.run()
or HystrixCommand.getFallback()
.@Deprecated public <T> java.lang.Exception onError(HystrixCommand<T> commandInstance, HystrixRuntimeException.FailureType failureType, java.lang.Exception e)
onError(com.netflix.hystrix.HystrixInvokable<T>, com.netflix.hystrix.exception.HystrixRuntimeException.FailureType, java.lang.Exception)
.
Invoked after failed completion of HystrixCommand
execution.commandInstance
- The executing HystrixCommand instance.failureType
- HystrixRuntimeException.FailureType
representing the type of failure that occurred.
See HystrixRuntimeException
for more information.
e
- Exception thrown by HystrixCommand
@Deprecated public <T> void onThreadStart(HystrixCommand<T> commandInstance)
onThreadStart(com.netflix.hystrix.HystrixInvokable<T>)
.
Invoked at start of thread execution when HystrixCommand
is executed using HystrixCommandProperties.ExecutionIsolationStrategy.THREAD
.commandInstance
- The executing HystrixCommand instance.@Deprecated public <T> void onThreadComplete(HystrixCommand<T> commandInstance)
onThreadComplete(com.netflix.hystrix.HystrixInvokable<T>)
.
Invoked at completion of thread execution when HystrixCommand
is executed using HystrixCommandProperties.ExecutionIsolationStrategy.THREAD
.
This will get invoked if the Hystrix thread successfully executes, regardless of whether the calling thread
encountered a timeout.commandInstance
- The executing HystrixCommand instance.