Hello all,

I am working on a full traceability solution on my camel routes, for that, I
am using a custom interceptor.

The problem is that the parent-child relation is not correctly set when
InterceptStrategy.wrapProcessorInInterceptors() is called.

I am working with a patched camel 2.2.0, to include ticket 3928
https://issues.apache.org/jira/browse/CAMEL-3928
Also, I repeated the tests with the last snapshot: revision 1130773, with
same results.

For example, in the following route:

from("direct:start").routeId("route")
        .choice().id("choice")
            .when(new XPathExpression("/x")).id("when")
                .log(" A").id("task1")
                .log(" B").id("task2")
            .otherwise().id("otherwise")
                .log(" C").id("task3")
            .end()
        .to("mock:done");

I use a custom interceptor to show each processor and its parent:

getContext().addInterceptStrategy(new InterceptStrategy() {
            @Override
            public Processor wrapProcessorInInterceptors(CamelContext
context, ProcessorDefinition<?> definition, final Processor target,
Processor nextTarget) throws Exception {
                String targetId = definition.hasCustomIdAssigned() ?
definition.getId() : definition.getLabel();
                ProcessorDefinition<?> parentDefinition =
definition.getParent();

                String parentId = null;

                if(parentDefinition != null){
                    parentId = parentDefinition.hasCustomIdAssigned() ?
parentDefinition.getId() : parentDefinition.getLabel();
                }

                logger.info(">>>>>>>>> parentId="+parentId+"
targetId="+targetId);

                return new Processor() {//return mock-empty processor.
                    @Override
                    public void process(Exchange exchange) throws Exception
{
                        // mock processor
                        target.process(exchange);
                    }
                };
            }
        });


I was expecting the following output:

parent: when targetid: task1
parent: when targetid: task2
parent: otherwise targetid: task3

Also, as you can notice, each processorDefinition is handled twice, anybody
knows why?

The output is:
INFO: >>>>>>>>> parentId=otherwise targetId=task1
INFO: >>>>>>>>> parentId=otherwise targetId=task1
INFO: >>>>>>>>> parentId=otherwise targetId=task2
INFO: >>>>>>>>> parentId=otherwise targetId=task2
INFO: >>>>>>>>> parentId=otherwise targetId=task3
INFO: >>>>>>>>> parentId=otherwise targetId=task3
INFO: >>>>>>>>> parentId=route targetId=otherwise
INFO: >>>>>>>>> parentId=route targetId=otherwise
INFO: >>>>>>>>> parentId=route targetId=mock:done
INFO: >>>>>>>>> parentId=route targetId=mock:done

Thank you very much.
Javier Arias.

Reply via email to