Search code examples
xpathapache-cameljsonpathblueprint-osgi

camel:when on header value using blueprint


I have camel routes that make rest calls based on header values. I had been using xpath to read values from xml and set them as the header and used xpath in a block as so:

 <camel:setHeader headerName="clear">
    <xpath>/TicketInfo/TicketData/Clear/text()</xpath>
 </camel:setHeader>
    <camel:choice>
       <camel:when>
          <camel:xpath>$clear='CLEARED'</camel:xpath>
          <camel:doTry>
              ...

but now I am forced to use json so xpath will not work. I now have:

<camel:setHeader headerName="clear">
   <camel:jsonpath>$.ticket.Type</camel:jsonpath>
</camel:setHeader>
   <camel:choice>
      <camel:when>
         <camel:xpath>$clear='CLEARED'</camel:xpath>
         <camel:doTry>
            ...

but obviously the <camel:xpath>$clear='CLEARED'</camel:xpath> part won't work anymore. Is there another way I can check the value of $clear header to restrict when the <camel:doTry> and following execute?


Solution

  • Try the simple language :

    <camel:when>
         <camel:simple>${in.header.clear} == 'CLEARED'</camel:simple>
         <camel:doTry>
    

    See this documentation