Search in sources :

Example 16 with RuntimeExchangeException

use of org.apache.camel.RuntimeExchangeException 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

RuntimeExchangeException (org.apache.camel.RuntimeExchangeException)16 URISyntaxException (java.net.URISyntaxException)8 IOException (java.io.IOException)7 URI (java.net.URI)4 Exchange (org.apache.camel.Exchange)3 XMPPException (org.jivesoftware.smack.XMPPException)3 HttpString (io.undertow.util.HttpString)2 ProtocolException (java.net.ProtocolException)2 SmackException (org.jivesoftware.smack.SmackException)2 Message (org.jivesoftware.smack.packet.Message)2 File (java.io.File)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SQLException (java.sql.SQLException)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Destination (javax.jms.Destination)1 Message (javax.jms.Message)1 Session (javax.jms.Session)1 HttpMethods (org.apache.camel.component.http4.HttpMethods)1 UseMessageIdAsCorrelationIdMessageSentCallback (org.apache.camel.component.jms.reply.UseMessageIdAsCorrelationIdMessageSentCallback)1