Package org.apache.camel.spi

Examples of org.apache.camel.spi.TraceableUnitOfWork


    // START SNIPPET: e2
    private class MyErrorProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
            // cast to TraceableUnitOfWork so we can work on the intercepted node path
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();

            // get the list of intercepted nodes
            List<RouteNode> list = tuow.getNodes();
            // get the 3rd last as its the bean
            Processor last = list.get(list.size() - 3).getProcessor();

            // set error message
            exchange.getFault().setBody("Failed at: " + last.toString());
View Full Code Here


            // before
            if (shouldLog) {

                // register route path taken if TraceableUnitOfWork unit of work
                if (exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
                    TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();

                    if (node instanceof OnExceptionDefinition) {
                        // special for on exception so we can see it in the trace logs
                        trace = beforeOnException((OnExceptionDefinition) node, tuow, exchange);
                    } else if (node instanceof OnCompletionDefinition) {
                        // special for on completion so we can see it in the trace logs
                        trace = beforeOnCompletion((OnCompletionDefinition) node, tuow, exchange);
                    } else {
                        // regular so just add it
                        tuow.addTraced(new DefaultRouteNode(node, super.getProcessor()));
                    }
                }
            }

            // log and trace the processor
            if (trace) {
                logExchange(exchange);
                traceExchange(exchange);
            }

            // some nodes need extra work to trace it
            if (exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
                TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();

                if (node instanceof InterceptDefinition) {
                    // special for intercept() as we would like to trace the processor that was intercepted
                    // as well, otherwise we only see the intercepted route, but we need the both to be logged/traced
                    afterIntercept((InterceptDefinition) node, tuow, exchange);
View Full Code Here

        return exchange.getExchangeId().substring(exchange.getExchangeId().indexOf("/") + 1);
    }

    private static String extractFromNode(Exchange exchange) {
        if (exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();
            RouteNode last = tuow.getSecondLastNode();
            return last != null ? last.getLabel(exchange) : null;
        }
        return null;
    }
View Full Code Here

        return null;
    }

    private static String extractToNode(Exchange exchange) {
        if (exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();
            RouteNode last = tuow.getLastNode();
            return last != null ? last.getLabel(exchange) : null;
        }
        return null;
    }
View Full Code Here

        // compute from and to
        String from = "";
        String to = "";
        if (showNode && exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();

            RouteNode traceFrom = tuow.getSecondLastNode();
            if (traceFrom != null) {
                from = getNodeMessage(traceFrom, exchange);
            } else if (exchange.getFromEndpoint() != null) {
                from = "from(" + exchange.getFromEndpoint().getEndpointUri() + ")";
            }

            RouteNode traceTo = tuow.getLastNode();
            if (traceTo != null) {
                to = getNodeMessage(traceTo, exchange);
            }
        }
View Full Code Here

    // START SNIPPET: e2
    private class MyErrorProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
            // cast to TraceableUnitOfWork so we can work on the intercepted node path
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();

            // get the list of intercepted nodes
            List<RouteNode> list = tuow.getNodes();
            // get the 3rd last as its the bean
            Processor last = list.get(list.size() - 3).getProcessor();

            // set error message
            exchange.getOut().setFault(true);
View Full Code Here

                logExchange(exchange);
                traceExchange(exchange);

                // if traceable then register this as the previous node, now it has been logged
                if (exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
                    TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();
                    tuow.addInterceptedNode(node);
                }
            }

            // process the exchange
            super.proceed(exchange);
View Full Code Here

        return exchange.getExchangeId().substring(exchange.getExchangeId().indexOf("/") + 1);
    }

    private String extractPreviousNode(Exchange exchange) {
        if (exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();
            ProcessorDefinition last = tuow.getLastInterceptedNode();
            return last != null ? extractNode(last) : null;
        }
        return null;
    }
View Full Code Here

        }

        // compute from and to
        String from = "";
        if (showNode && exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();
            ProcessorDefinition prev = tuow.getLastInterceptedNode();
            if (prev != null) {
                from = getNodeMessage(prev);
            } else if (exchange.getFromEndpoint() != null) {
                from = exchange.getFromEndpoint().getEndpointUri();
            }
View Full Code Here

    // START SNIPPET: e2
    private class MyErrorProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
            // cast to TraceableUnitOfWork so we can work on the intercepted node path
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();

            // get the list of intercepted nodes
            List<ProcessorDefinition> list = tuow.getInterceptedNodes();
            // get the 2nd last as the last is me (MyErrorProcessor)
            ProcessorDefinition last = list.get(list.size() - 2);

            // set error message
            exchange.getFault().setBody("Failed at: " + last.getLabel());
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.TraceableUnitOfWork

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.