获取熔断与实例隔离告警事件

场景描述

  • 在微服务运行期间熔断或实例隔离状态发生变化时,需要监听到相关事件,获取相关信息并进行处理

使用参考

  • 监听熔断事件

    1. Object receiveEvent = new Object() {
    2. @Subscribe
    3. public void onEvent(CircutBreakerEvent circutBreakerEvent) {
    4. //Get information from circutBreakerEvent
    5. }
    6. };
    7. EventManager.getEventBus().register(receiveEvent);
  • 监听实例隔离事件

    1. Object receiveEvent = new Object() {
    2. @Subscribe
    3. public void onEvent(IsolationServerEvent isolationServerEvent) {
    4. //Get information from isolationServerEvent
    5. }
    6. };
    7. EventManager.getEventBus().register(receiveEvent);
  • 两个事件均监听

    1. Object receiveEvent = new Object() {
    2. @Subscribe
    3. public void onEvent(AlarmEvent alarmEvent) {
    4. //Get information from alarmEvent
    5. }
    6. };
    7. EventManager.getEventBus().register(receiveEvent);