我已经编写了 Camel 选择,路线的输入是xml。如下图所示: 我想用 json 作为输入来编写选择,那么如何评估 json 以路由到下一个组件。请指导我。 JSON 是:
{
"service": { "serviceType": "OtherServcie" }
}
<choice>
<when>
<xpath>/service/serviceType='PaymentServcie'</xpath>
<log message="In PaymentServcie"/>
</when>
<otherwise>
<log message="In OtherServcie"/>
</otherwise>
</choice>
最佳答案
也许为时已晚,但答案是使用 camel-jsonpath .
<route>
<from uri="direct:start"/>
<choice>
<when>
<jsonpath>$.service[?(@.serviceType=='PaymentService')]</jsonpath>
<log message="In PaymentServcie"/>
</when>
<otherwise>
<log message="In OtherServcie"/>
</otherwise>
</choice>
不要忘记 Maven 依赖项:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jsonpath</artifactId>
<version>${camel.version}</version>
</dependency>
关于json - 使用 json 进行 Camel 选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18824515/