com.netflix.hystrix.strategy.eventnotifier
Class HystrixEventNotifier

java.lang.Object
  extended by com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifier

public abstract class HystrixEventNotifier
extends java.lang.Object

Abstract EventNotifier that allows receiving notifications for different events with default implementations.

Custom implementations of this interface can be used to override default behavior via 2 mechanisms:

1) Injection

Implementations can be injected into HystrixCommand and HystrixCollapser implementation constructors.

2) Plugin

Using HystrixPlugins.registerEventNotifier(com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifier) an implementation can be registered globally to take precedence and override all other implementations.

The order of precedence is:

  1. plugin registered globally using HystrixPlugins.registerEventNotifier(com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifier)
  2. injected via HystrixCommand and HystrixCollapser constructors
  3. default implementation HystrixEventNotifierDefault

The injection approach is effective for HystrixCommand and HystrixCollapser implementations where you wish to have a different default mechanism for event notification without overriding all implementations. It is also useful when distributing a library where static override should not be used.

The globally registered plugin is useful when using commands from 3rd party libraries and you want to override how event notifications are performed for all implementations in your entire system.


Constructor Summary
HystrixEventNotifier()
           
 
Method Summary
 void markCommandExecution(HystrixCommandKey key, HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy, int duration, java.util.List<HystrixEventType> eventsDuringExecution)
          Called after a command is executed using thread isolation.
 void markEvent(HystrixEventType eventType, HystrixCommandKey key)
          Called for every event fired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HystrixEventNotifier

public HystrixEventNotifier()
Method Detail

markEvent

public void markEvent(HystrixEventType eventType,
                      HystrixCommandKey key)
Called for every event fired.

Default Implementation: Does nothing

Parameters:
eventType -
key -

markCommandExecution

public void markCommandExecution(HystrixCommandKey key,
                                 HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy,
                                 int duration,
                                 java.util.List<HystrixEventType> eventsDuringExecution)
Called after a command is executed using thread isolation.

Will not get called if a command is rejected, short-circuited etc.

Default Implementation: Does nothing

Parameters:
key - HystrixCommandKey of command instance.
isolationStrategy - HystrixCommandProperties.ExecutionIsolationStrategy the isolation strategy used by the command when executed
duration - time in milliseconds of executing run() method
eventsDuringExecution - List<HystrixEventType> of events occurred during execution.