188.6. Suppress exceptions
Camel 2.16 以降で利用可能
デフォルトでは、設定された jsonpath 式に従って json ペイロードに有効なパスがない場合には、jsonpath は例外を出力します。ユースケースによっては、json ペイロードにオプションのデータが含まれている時にはこれを無視する場合があります。したがって、以下に示すように、オプション suppressExceptions を true に設定して、これを無視できます。
from("direct:start") .choice() // use true to suppress exceptions .when().jsonpath("person.middlename", true) .to("mock:middle") .otherwise() .to("mock:other");
from("direct:start")
.choice()
// use true to suppress exceptions
.when().jsonpath("person.middlename", true)
.to("mock:middle")
.otherwise()
.to("mock:other");
そして XML DSL では:
<route> <from uri="direct:start"/> <choice> <when> <jsonpath suppressExceptions="true">person.middlename</jsonpath> <to uri="mock:middle"/> </when> <otherwise> <to uri="mock:other"/> </otherwise> </choice> </route>
<route>
<from uri="direct:start"/>
<choice>
<when>
<jsonpath suppressExceptions="true">person.middlename</jsonpath>
<to uri="mock:middle"/>
</when>
<otherwise>
<to uri="mock:other"/>
</otherwise>
</choice>
</route>
このオプションは、@JsonPath
アノテーションでも使用できます。