我如何使用 POLLENRICH 读取 JSON 文件内容

How do i read a JSON file content using POLLENRICH

我正在使用 Apache camel 版本 2.24.3,这是我的 JSON 文件内容

{
  "p-1":"smh_5000",
  "p-2":"smh_6000"
}

所以我想使用 pollenrich 阅读此内容文件:当我给他 p-1 时,他 returns smh_5000。 有人可以就如何在这个例子中使用 pollenrinch 提出建议。

<camelContext> 
<pollEnrich id="readFile" timeout="5000"> 
                <constant>file://data?fileName=test.json</constant> 
            </pollEnrich> 
     <log id="jsonData" message="The message contains ${body}"/> 
     <process id="readingparams" ref="ReadingP"/> 
</camelContext>

我的流程是:

public class ReadingP implements Processor { 
    @Override 
    public void process(Exchange exchange) throws Exception,JSONException {
                JSONObject json = (new JSONObject(exchange.getIn().getBody(String.class))).getJSONArray("catalogue").getJSONObject(0);
                Map<String,Object> ctx= exchange.getProperties();
                ctx.put("product-p", json.get("p-1"));
                exchange.getOut().setHeaders(exchange.getIn().getHeaders());
         }
}