187.7. インラインの単純な例外

Camel 2.18 から利用可能

単純な構文 ${xxx} を使用して、JSonPath 式で Simple 言語式をインライン化できるようになりました。以下に例を示します。

from("direct:start")
  .choice()
    .when().jsonpath("$.store.book[?(@.price < ${header.cheap})]")
      .to("mock:cheap")
    .when().jsonpath("$.store.book[?(@.price < ${header.average})]")
      .to("mock:average")
    .otherwise()
      .to("mock:expensive");

そして XML DSL では:

<route>
  <from uri="direct:start"/>
  <choice>
    <when>
      <jsonpath>$.store.book[?(@.price < ${header.cheap})]</jsonpath>
      <to uri="mock:cheap"/>
    </when>
    <when>
      <jsonpath>$.store.book[?(@.price < ${header.average})]</jsonpath>
      <to uri="mock:average"/>
    </when>
    <otherwise>
      <to uri="mock:expensive"/>
    </otherwise>
  </choice>
</route>

次のように、オプション allowSimple を false に設定して、インライン化された Simple 式のサポートを無効にすることができます。

.when().jsonpath("$.store.book[?(@.price < 10)]", false, false)

そして XML DSL では:

<jsonpath allowSimple="false">$.store.book[?(@.price < 10)]</jsonpath>