I've written camel choice and input for route is xml. shown below: I want to write choice with json as an input so how to evaluate the json to route to next component. Kindly guide me. JSON is:
{
"service": { "serviceType": "OtherServcie" }
}
<choice>
<when>
<xpath>/service/serviceType='PaymentServcie'</xpath>
<log message="In PaymentServcie"/>
</when>
<otherwise>
<log message="In OtherServcie"/>
</otherwise>
</choice>
Maybe too late, but the answer is to use 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>
Don't forget the Maven dependency :
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jsonpath</artifactId>
<version>${camel.version}</version>
</dependency>