camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier Arias Losada <>
Subject wrong processordefinitions in InterceptStrategy.wrapProcessorInInterceptors - choice+when+otherwise
Date Thu, 02 Jun 2011 21:44:32 GMT
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
Also, I repeated the tests with the last snapshot: revision 1130773, with
same results.

For example, in the following route:

            .when(new XPathExpression("/x")).id("when")
                .log(" A").id("task1")
                .log(" B").id("task2")
                .log(" C").id("task3")

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

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

                String parentId = null;

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

      ">>>>>>>>> parentId="+parentId+"

                return new Processor() {//return mock-empty processor.
                    public void process(Exchange exchange) throws Exception
                        // mock processor

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.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message