Camel JsonPath蓝图

Camel JsonPath蓝图,json,substring,blueprint,Json,Substring,Blueprint,我有一个Json: {"request": {"cc": "000120000111SS000222M" }} 这个蓝图: <route id="SGPIF-bonifico-dynamic-jetty"> <from uri="jetty:http://0.0.0.0:9100/ifom/esterno/bonifico/dynamic?matchOnUriPrefix=true"/> <choice> &

我有一个Json:

{"request": {"cc": "000120000111SS000222M" }}
这个蓝图:

<route id="SGPIF-bonifico-dynamic-jetty">
      <from uri="jetty:http://0.0.0.0:9100/ifom/esterno/bonifico/dynamic?matchOnUriPrefix=true"/>
         <choice>
          <when>
          <jsonpath suppressExceptions="true">request.cc=~'0000111'</jsonpath>
          <log message="Json choice equals "/>
           <log message="SGPIF-bonifico-dynamic-jetty header: ${headers}"/>
           <to uri="log:SGPIF-bonifico-dynamic-jetty" />
           <wireTap uri="direct:requestEvent"/>
           <to uri="jetty:http://127.0.0.1:8080/om/esterno/bonifico/dynamic?bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>
           <log message="SGPIF-bonifico-dynamic-jetty-done header: ${headers}"/>
           <wireTap uri="direct:responseEvent"/>
           <to uri="log:SGPIF-bonifico-dynamic-jetty-done" />
         </when>
          <otherwise>
           <log message="Else choice"/>
           <log message="SGPIF-bonifico-dynamic-jetty header: ${headers}"/>
           <to uri="log:SGPIF-bonifico-dynamic-jetty" />
           <wireTap uri="direct:requestEvent"/>
           <to uri="jetty:http://127.0.0.1:8080/ifom/esterno/bonifico/dynamic?bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>
           <log message="SGPIF-bonifico-dynamic-jetty-done header: ${headers}"/>
           <wireTap uri="direct:responseEvent"/>
           <to uri="log:SGPIF-bonifico-dynamic-jetty-done" />
          </otherwise>
        </choice>
    </route>

如果先将值放在标题中,然后用简单语言计算标题值,会怎么样?见下文

<setHeader headerName="CamelRequestCc">
  <jsonpath>$.request.cc</jsonpath>
</setHeader>

<choice>
  <when>
  <simple>${header.CamelRequestCc} contains '0000111'</simple>
    <log message="Json choice equals "/>
    ...

$.request.cc
${header.CamelRequestCc}包含“0000111”
...

您可以ommit setHeader部分并编写以下方法public void doSomething(@JsonPath($.request.cc”)String jsonValue,@Headers Map Headers){Headers.put(“jsonValue”,jsonValue.substring(5,12));}非常感谢您的工作!
    public void doSomething(@Header("JsonValue") String jsonValue, @Body String body) {
    jsonValue += jsonValue.substring(5,12);

}
<setHeader headerName="CamelRequestCc">
  <jsonpath>$.request.cc</jsonpath>
</setHeader>

<choice>
  <when>
  <simple>${header.CamelRequestCc} contains '0000111'</simple>
    <log message="Json choice equals "/>
    ...