Apache Camel: Nested filters (filter ... filter ... end ...filter ... end ..end) in DSL (Groovy or Java) -


we have issues dsl camel routes. seems not possible translate following xml configuration groovy (or java) dsl

    <route id="myroute" >         <from uri="fromuri" />         <filter>             <xpath>//entity[contains(@destinations, 'databasedestination')]</xpath>             <filter>                 <xpath>//entity[@objecttype = 'objecttype']</xpath>                 <camel:setheader headername="bodytemp">                     <simple>${body}</simple>                 </camel:setheader>                 <filter>                     <xpath>//entity[@command = 'add']</xpath>                     <convertbodyto type="com.foo.bar.entity" />                     <bean ref="handler" method="add" />                 </filter>                 <filter>                     <xpath>//entity[@command = 'foo']</xpath>                     <convertbodyto type="com.foo.bar.entity" />                     <bean ref="handler" method="foo" />                 </filter>                 <filter>                     <xpath>//entity[@command = 'bar']</xpath>                     <convertbodyto type="com.foo.bar.entity" />                     <bean ref="handler" method="bar" />                 </filter>                 <to uri="touri" />                   </filter>         </filter>     </route> 

wie tried translate inside groovy based routebuilder follows:

from("fromuri")         .filter().xpath('//entity[contains(@destinations, \'databasedestination\')]')             .setheader("bodytemp", simple('${body}'))             .filter().xpath('//entity[@objecttype = \'objecttype\']')                  .filter().xpath('//entity[@command = \'add\']')                     .convertbodyto(com.foo.bar.entity)                     .bean(handler, "add")                    .end()                 .filter().xpath('//entity[@command = \'foo\']')                     .convertbodyto(com.foo.bar.entity)                     .bean(handler, "foo")                 .end()                 .filter().xpath('//entity[@command = \'bar\']')                     .convertbodyto(com.foo.bar.entity)                     .bean(handler, "bar")                 .end()                  .to("touri")             .end()         .end()   

but doesn't work. javax.xml.xpath.xpathexpressionexception message: invalid xpath: //entity[@command = 'foo']

see corresponding stacktrace well.

     ->>  814 | doinevaluateas      in org.apache.camel.builder.xml.xpathbuilder     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      |    697 | evaluateas          in     ''     |    139 | matches . . . . . . in     ''     |     47 | process             in org.apache.camel.processor.filterprocessor     |     73 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |     99 | processnext         in org.apache.camel.processor.delegateasyncprocessor     |     90 | process . . . . . . in     ''     |     73 | process             in org.apache.camel.management.instrumentationprocessor     |     99 | processnext . . . . in org.apache.camel.processor.delegateasyncprocessor     |     90 | process             in     ''     |     91 | process . . . . . . in             org.apache.camel.processor.interceptor.traceinterceptor     |     73 | process             in org.apache.camel.util.asyncprocessorhelper     |    330 | processerrorhandler in org.apache.camel.processor.redeliveryerrorhandler     |    220 | process             in     ''     |     45 | processnext . . . . in org.apache.camel.processor.routecontextprocessor     |     90 | process             in org.apache.camel.processor.delegateasyncprocessor     |    303 | process . . . . . . in org.apache.camel.processor.interceptor.defaultchannel     |     73 | process             in org.apache.camel.util.asyncprocessorhelper     |    117 | process . . . . . . in org.apache.camel.processor.pipeline     |     80 | process             in     ''     |     45 | processnext . . . . in org.apache.camel.processor.routecontextprocessor     |     90 | process             in org.apache.camel.processor.delegateasyncprocessor     |    150 | processasync . . .  in org.apache.camel.processor.unitofworkprocessor     |    117 | process             in     ''     |     48 | processnext . . . . in     org.apache.camel.processor.routeinflightrepositoryprocessor     |     90 | process             in org.apache.camel.processor.delegateasyncprocessor     |     73 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |     99 | processnext         in org.apache.camel.processor.delegateasyncprocessor     |     90 | process . . . . . . in     ''     |     73 | process             in org.apache.camel.management.instrumentationprocessor     |     99 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |     86 | process             in org.apache.camel.processor.delegateasyncprocessor     |    105 | onmessage . . . . . in    org.apache.camel.component.jms.endpointmessagelistener     |   1110 | runworker           in java.util.concurrent.threadpoolexecutor     |    603 | run . . . . . . . . in java.util.concurrent.threadpoolexecutor$worker     ^    722 | run                 in java.lang.thread     caused xpathexpressionexception: null     ->>  200 | evaluate            in     com.sun.org.apache.xpath.internal.jaxp.xpathexpressionimpl     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      |    800 | doinevaluateas      in org.apache.camel.builder.xml.xpathbuilder     |    697 | evaluateas . . . .  in     ''     |    139 | matches             in     ''     |     47 | process . . . . . . in org.apache.camel.processor.filterprocessor     |     73 | process             in org.apache.camel.util.asyncprocessorhelper     |     99 | processnext . . . . in org.apache.camel.processor.delegateasyncprocessor     |     90 | process             in     ''     |     73 | process . . . . . . in org.apache.camel.management.instrumentationprocessor     |     99 | processnext         in org.apache.camel.processor.delegateasyncprocessor     |     90 | process . . . . . . in     ''     |     91 | process             in    org.apache.camel.processor.interceptor.traceinterceptor     |     73 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |    330 | processerrorhandler in org.apache.camel.processor.redeliveryerrorhandler     |    220 | process . . . . . . in     ''     |     45 | processnext         in org.apache.camel.processor.routecontextprocessor     |     90 | process . . . . . . in org.apache.camel.processor.delegateasyncprocessor     |    303 | process             in org.apache.camel.processor.interceptor.defaultchannel     |     73 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |    117 | process             in org.apache.camel.processor.pipeline     |     80 | process . . . . . . in     ''     |     45 | processnext         in org.apache.camel.processor.routecontextprocessor     |     90 | process . . . . . . in org.apache.camel.processor.delegateasyncprocessor     |    150 | processasync        in org.apache.camel.processor.unitofworkprocessor     |    117 | process . . . . . . in     ''     |     48 | processnext         in      org.apache.camel.processor.routeinflightrepositoryprocessor     |     90 | process . . . . . . in org.apache.camel.processor.delegateasyncprocessor     |     73 | process             in org.apache.camel.util.asyncprocessorhelper     |     99 | processnext . . . . in org.apache.camel.processor.delegateasyncprocessor     |     90 | process             in     ''     |     73 | process . . . . . . in org.apache.camel.management.instrumentationprocessor     |     99 | process             in org.apache.camel.util.asyncprocessorhelper     |     86 | process . . . . . . in org.apache.camel.processor.delegateasyncprocessor     |    105 | onmessage           in     org.apache.camel.component.jms.endpointmessagelistener     |   1110 | runworker . . . . . in java.util.concurrent.threadpoolexecutor     |    603 | run                 in java.util.concurrent.threadpoolexecutor$worker     ^    722 | run . . . . . . . . in java.lang.thread     caused transformerexception: unable evaluate expression using context     ->>  367 | execute             in com.sun.org.apache.xpath.internal.xpath      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      |    129 | eval                in     com.sun.org.apache.xpath.internal.jaxp.xpathexpressionimpl     |    105 | eval . . . . . . .  in     ''     |    187 | evaluate            in     ''     |    800 | doinevaluateas . .  in org.apache.camel.builder.xml.xpathbuilder     |    697 | evaluateas          in     ''     |    139 | matches . . . . . . in     ''     |     47 | process             in org.apache.camel.processor.filterprocessor     |     73 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |     99 | processnext         in org.apache.camel.processor.delegateasyncprocessor     |     90 | process . . . . . . in     ''     |     73 | process             in org.apache.camel.management.instrumentationprocessor     |     99 | processnext . . . . in org.apache.camel.processor.delegateasyncprocessor     |     90 | process             in     ''     |     91 | process . . . . . . in     org.apache.camel.processor.interceptor.traceinterceptor     |     73 | process             in org.apache.camel.util.asyncprocessorhelper     |    330 | processerrorhandler in org.apache.camel.processor.redeliveryerrorhandler     |    220 | process             `enter code here`in     ''     |     45 | processnext . . . . in org.apache.camel.processor.routecontextprocessor     |     90 | process             in org.apache.camel.processor.delegateasyncprocessor     |    303 | process . . . . . . in org.apache.camel.processor.interceptor.defaultchannel     |     73 | process             in org.apache.camel.util.asyncprocessorhelper     |    117 | process . . . . . . in org.apache.camel.processor.pipeline     |     80 | process             in     ''     |     45 | processnext . . . . in org.apache.camel.processor.routecontextprocessor     |     90 | process             in org.apache.camel.processor.delegateasyncprocessor     |    150 | processasync . . .  in org.apache.camel.processor.unitofworkprocessor     |    117 | process             in     ''     |     48 | processnext . . . . in     org.apache.camel.processor.routeinflightrepositoryprocessor     |     90 | process             in org.apache.camel.processor.delegateasyncprocessor     |     73 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |     99 | processnext         in org.apache.camel.processor.delegateasyncprocessor     |     90 | process . . . . . . in     ''     |     73 | process             in org.apache.camel.management.instrumentationprocessor     |     99 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |     86 | process             in org.apache.camel.processor.delegateasyncprocessor     |    105 | onmessage . . . . . in     org.apache.camel.component.jms.endpointmessagelistener     |   1110 | runworker           in java.util.concurrent.threadpoolexecutor     |    603 | run . . . . . . . . in java.util.concurrent.threadpoolexecutor$worker     ^    722 | run                 in java.lang.thread     caused runtimeexception: unable evaluate expression using context     ->>  266 | setroot             in com.sun.org.apache.xpath.internal.axes.nodesequence     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -      |    214 | execute             in     com.sun.org.apache.xpath.internal.axes.locpathiterator     |    339 | execute . . . . . . in com.sun.org.apache.xpath.internal.xpath     |    129 | eval                in     com.sun.org.apache.xpath.internal.jaxp.xpathexpressionimpl     |    105 | eval . . . . . . .  in     ''     |    187 | evaluate            in     ''     |    800 | doinevaluateas . .  in org.apache.camel.builder.xml.xpathbuilder     |    697 | evaluateas          in     ''     |    139 | matches . . . . . . in     ''     |     47 | process             in org.apache.camel.processor.filterprocessor     |     73 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |     99 | processnext         in org.apache.camel.processor.delegateasyncprocessor     |     90 | process . . . . . . in     ''     |     73 | process             in org.apache.camel.management.instrumentationprocessor     |     99 | processnext . . . . in org.apache.camel.processor.delegateasyncprocessor     |     90 | process             in     ''     |     91 | process . . . . . . in     org.apache.camel.processor.interceptor.traceinterceptor     |     73 | process             in org.apache.camel.util.asyncprocessorhelper     |    330 | processerrorhandler in org.apache.camel.processor.redeliveryerrorhandler     |    220 | process             in     ''     |     45 | processnext . . . . in org.apache.camel.processor.routecontextprocessor     |     90 | process             in org.apache.camel.processor.delegateasyncprocessor     |    303 | process . . . . . . in org.apache.camel.processor.interceptor.defaultchannel     |     73 | process             in org.apache.camel.util.asyncprocessorhelper     |    117 | process . . . . . . in org.apache.camel.processor.pipeline     |     80 | process             in     ''     |     45 | processnext . . . . in org.apache.camel.processor.routecontextprocessor     |     90 | process             in org.apache.camel.processor.delegateasyncprocessor     |    150 | processasync . . .  in org.apache.camel.processor.unitofworkprocessor     |    117 | process             in     ''     |     48 | processnext . . . . in     org.apache.camel.processor.routeinflightrepositoryprocessor     |     90 | process             in org.apache.camel.processor.delegateasyncprocessor     |     73 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |     99 | processnext         in org.apache.camel.processor.delegateasyncprocessor     |     90 | process . . . . . . in     ''     |     73 | process             in org.apache.camel.management.instrumentationprocessor     |     99 | process . . . . . . in org.apache.camel.util.asyncprocessorhelper     |     86 | process             in org.apache.camel.processor.delegateasyncprocessor     |    105 | onmessage . . . . . in     org.apache.camel.component.jms.endpointmessagelistener     |   1110 | runworker           in java.util.concurrent.threadpoolexecutor     |    603 | run . . `enter code here`. . . . . . in     java.util.concurrent.threadpoolexecutor$worker     ^    722 | run                 in java.lang.thread  

thank help

markus

your code seems more fitting content based router, making use of choice eip.

are able make use of choice statement instead? http://camel.apache.org/content-based-router.html


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -