Java 类org.apache.camel.management.event.ExchangeFailedEvent 实例源码

项目:springboot-camel-metrics-publisher    文件:CamelMetricsUpdater.java   
@Override
public void notify(EventObject event) throws Exception {
    boolean covered = false;

    if (event instanceof AbstractExchangeEvent) {
        AbstractExchangeEvent ev = AbstractExchangeEvent.class.cast(event);

        final Exchange exchange = ev.getExchange();
        String metricPrefix = exchange.getFromRouteId();

        // if we can't find the prefix for the metrics then don't capture any
        if (metricPrefix == null || metricPrefix.equals("")) { return; }

        if (ev instanceof ExchangeCompletedEvent || ev instanceof ExchangeFailedEvent || ev instanceof ExchangeRedeliveryEvent) {
            onExchangeCompletedEvent(ev, metricPrefix);
            covered = true;
        } else {
            metrics.meter(name(event.getClass(), metricPrefix)).mark();
        }
    }

    if (!covered)
        LOGGER.debug("Not covered: Type {} ({})", event.getClass(), event);
}
项目:Camel    文件:DebugExceptionEventBreakpointTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();

    breakpoint = new BreakpointSupport() {
        public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
            AbstractExchangeEvent aee = (AbstractExchangeEvent) event;
            Exception e = aee.getExchange().getException();
            logs.add("Breakpoint at " + definition + " caused by: " + e.getClass().getSimpleName() + "[" + e.getMessage() + "]");
        }
    };

    exceptionCondition = new ConditionSupport() {
        public boolean matchEvent(Exchange exchange, EventObject event) {
            return event instanceof ExchangeFailedEvent;
        }
    };
}
项目:Camel    文件:NagiosEventNotifier.java   
protected Level determineLevel(EventObject eventObject) {
    // failures is considered critical
    if (eventObject instanceof ExchangeFailedEvent
            || eventObject instanceof CamelContextStartupFailureEvent
            || eventObject instanceof CamelContextStopFailureEvent
            || eventObject instanceof ServiceStartupFailureEvent
            || eventObject instanceof ServiceStopFailureEvent) {
        return Level.CRITICAL;
    }

    // the failure was handled so its just a warning
    // and warn when a redelivery attempt is done
    if (eventObject instanceof ExchangeFailureHandledEvent
            || eventObject instanceof ExchangeRedeliveryEvent) {
        return Level.WARNING;
    }

    // default to OK
    return Level.OK;
}
项目:Camel    文件:NotifyBuilder.java   
public void notify(EventObject event) throws Exception {
    if (event instanceof ExchangeCreatedEvent) {
        onExchangeCreated((ExchangeCreatedEvent) event);
    } else if (event instanceof ExchangeCompletedEvent) {
        onExchangeCompleted((ExchangeCompletedEvent) event);
    } else if (event instanceof ExchangeFailedEvent) {
        onExchangeFailed((ExchangeFailedEvent) event);
    } else if (event instanceof ExchangeSentEvent) {
        onExchangeSent((ExchangeSentEvent) event);
    }

    // now compute whether we matched
    computeMatches();
}
项目:Camel    文件:EventNotifierEventsTest.java   
public void testExchangeFailed() throws Exception {
    try {
        template.sendBody("direct:fail", "Hello World");
        fail("Should have thrown an exception");
    } catch (Exception e) {
        // expected
        assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
    }

    assertEquals(10, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(2));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(3));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(4));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(5));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(6));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeFailedEvent.class, events.get(8));
    // this is the sent using the produce template to start the test
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));

    context.stop();

    assertEquals(16, events.size());
    assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(10));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(11));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(12));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(13));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(14));
    assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(15));
}
项目:Camel    文件:MultipleEventNotifierEventsTest.java   
public void testExchangeFailed() throws Exception {
    try {
        template.sendBody("direct:fail", "Hello World");
        fail("Should have thrown an exception");
    } catch (Exception e) {
        // expected
        assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
    }

    assertEquals(10, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(2));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(3));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(4));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(5));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(6));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeFailedEvent.class, events.get(8));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));

    assertEquals(4, events2.size());

    context.stop();
    assertIsInstanceOf(ExchangeSendingEvent.class, events2.get(0));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events2.get(1));
    assertIsInstanceOf(ExchangeFailedEvent.class, events2.get(2));
    assertIsInstanceOf(ExchangeSentEvent.class, events2.get(3));

    assertEquals(16, events.size());
    assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(10));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(11));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(12));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(13));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(14));
    assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(15));

    assertEquals(4, events2.size());
}
项目:Camel    文件:ZipkinTracer.java   
@Override
public boolean isEnabled(EventObject event) {
    return event instanceof ExchangeSendingEvent
            || event instanceof ExchangeSentEvent
            || event instanceof ExchangeCreatedEvent
            || event instanceof ExchangeCompletedEvent
            || event instanceof ExchangeFailedEvent;
}
项目:camelinaction2    文件:RiderEventNotifier.java   
public void notify(EventObject eventObject) throws Exception {
    if (eventObject instanceof ExchangeFailedEvent) {
        ExchangeFailedEvent event = (ExchangeFailedEvent) eventObject;
        String id = event.getExchange().getExchangeId();
        Exception cause = event.getExchange().getException();
        Date now = new Date();

        publisher.publish(appId, id, now, cause.getMessage());
    }
}
项目:camelinaction    文件:RiderEventNotifier.java   
protected void notifyFailure(ExchangeFailedEvent event) {
    String id = event.getExchange().getExchangeId();
    Exception cause = event.getExchange().getException();
    Date now = new Date();

    publisher.publish(appId, id, now, cause.getMessage());
}
项目:t4f-data    文件:RiderEventNotifier.java   
protected void notifyFailure(ExchangeFailedEvent event) {
    String id = event.getExchange().getExchangeId();
    Exception cause = event.getExchange().getException();
    Date now = new Date();

    publisher.publish(appId, id, now, cause.getMessage());
}
项目:t4f-data    文件:RiderEventNotifier.java   
protected void notifyFailure(ExchangeFailedEvent event) {
    String id = event.getExchange().getExchangeId();
    Exception cause = event.getExchange().getException();
    Date now = new Date();

    publisher.publish(appId, id, now, cause.getMessage());
}
项目:Camel    文件:NotifyBuilder.java   
private void onExchangeFailed(ExchangeFailedEvent event) {
    for (EventPredicateHolder predicate : predicates) {
        predicate.getPredicate().onExchangeFailed(event.getExchange());
    }
}
项目:camelinaction2    文件:RiderEventNotifier.java   
public boolean isEnabled(EventObject eventObject) {
    // can be used for fine grained to determine whether to notify this event or not

    // we only want to notify in case of failures
    return eventObject instanceof ExchangeFailedEvent;
}
项目:camelinaction    文件:RiderEventNotifier.java   
public void notify(EventObject eventObject) throws Exception {
    // we only want to notify in case of failures
    if (eventObject instanceof ExchangeFailedEvent) {
        notifyFailure((ExchangeFailedEvent) eventObject);
    }
}
项目:t4f-data    文件:RiderEventNotifier.java   
public void notify(EventObject eventObject) throws Exception {
    // we only want to notify in case of failures
    if (eventObject instanceof ExchangeFailedEvent) {
        notifyFailure((ExchangeFailedEvent) eventObject);
    }
}
项目:t4f-data    文件:RiderEventNotifier.java   
public void notify(EventObject eventObject) throws Exception {
    // we only want to notify in case of failures
    if (eventObject instanceof ExchangeFailedEvent) {
        notifyFailure((ExchangeFailedEvent) eventObject);
    }
}