Camel-JsonPath 蓝图

Camel-JsonPath 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>
          <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>

在这种情况下,如果此值 0000111 存在于 json 中,我将进行过滤。我可以按职位筛选吗?我想在这个 000120000111SS000222M 上做一个子串。 有什么办法吗?

好的 contains.But 没问题 我需要这样的东西:

setHeader headerName="JsonValue">
          <jsonpath>$.request.cc</jsonpath>
         </setHeader>
         <bean ref="parser" method="doSomething"/>
         <choice>
          <when>
          <simple>${header.JsonValue} == '0000111'</simple>

并尝试做这样的事情:

    public void doSomething(@Header("JsonValue") String jsonValue, @Body String body) {
    jsonValue += jsonValue.substring(5,12);

}

如果先把值放在header中,然后用简单的语言计算header的值呢?见下文

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

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