Search in sources :

Example 1 with AbstractExchangeEvent

use of org.apache.camel.management.event.AbstractExchangeEvent in project camel by apache.

the class DebugExceptionEventBreakpointTest method setUp.

@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;
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) ExchangeFailedEvent(org.apache.camel.management.event.ExchangeFailedEvent) BreakpointSupport(org.apache.camel.impl.BreakpointSupport) ConditionSupport(org.apache.camel.impl.ConditionSupport) AbstractExchangeEvent(org.apache.camel.management.event.AbstractExchangeEvent) EventObject(java.util.EventObject)

Example 2 with AbstractExchangeEvent

use of org.apache.camel.management.event.AbstractExchangeEvent in project camel by apache.

the class CdiEventConsumer method notify.

void notify(T event) {
    logger.debug("Consuming CDI event [{}] with {}", event, this);
    Exchange exchange = getEndpoint().createExchange();
    // TODO: would that be possible to propagate the event metadata?
    exchange.getIn().setBody(event);
    // Avoid infinite loop of exchange events
    if (event instanceof AbstractExchangeEvent) {
        exchange.setProperty(Exchange.NOTIFY_EVENT, Boolean.TRUE);
    }
    try {
        getProcessor().process(exchange);
    } catch (Exception cause) {
        throw new RuntimeExchangeException("Error while processing CDI event", exchange, cause);
    } finally {
        if (event instanceof AbstractExchangeEvent) {
            exchange.setProperty(Exchange.NOTIFY_EVENT, Boolean.FALSE);
        }
    }
}
Also used : Exchange(org.apache.camel.Exchange) RuntimeExchangeException(org.apache.camel.RuntimeExchangeException) AbstractExchangeEvent(org.apache.camel.management.event.AbstractExchangeEvent) RuntimeExchangeException(org.apache.camel.RuntimeExchangeException)

Aggregations

Exchange (org.apache.camel.Exchange)2 AbstractExchangeEvent (org.apache.camel.management.event.AbstractExchangeEvent)2 EventObject (java.util.EventObject)1 RuntimeExchangeException (org.apache.camel.RuntimeExchangeException)1 BreakpointSupport (org.apache.camel.impl.BreakpointSupport)1 ConditionSupport (org.apache.camel.impl.ConditionSupport)1 ExchangeFailedEvent (org.apache.camel.management.event.ExchangeFailedEvent)1