骆驼json-validator抛出流关闭异常

时间:2018-09-07 19:38:19

标签: apache-camel

我正在尝试根据模式验证json负载,并尝试使用“ camel-json-validator”。 这是我的配置方式。

 public void configure() throws Exception {
    onException(CamelException.class, CamelExecutionException.class, Exception.class).handled(true).bean(WcaExceptionProcessor.class,
            "handleException");
    restConfiguration().component("servlet").bindingMode(RestBindingMode.auto)
            // and output using pretty print
            .dataFormatProperty("prettyPrint", "true")
            .dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES");

    rest("/retrieve")
            .consumes("application/json").produces("application/json")//.bindingMode(RestBindingMode.json)
            .post()
            .type(UsersRetrieveRequest.class)
            .to("direct:userRetrieve");


    from("direct:userRetrieve")
            .doTry()
                .to("json-validator:userRetrieve.json")
                .bean("wcaResource", "postUersRetrieve")

            .doCatch(ValidationException.class)
                .log("failed ******")
                .throwException(ValidationException.class, "JSon Validation exception");



}

当代码运行时,如果字段的长度大于允许的最大值,则我期望验证异常。但是,出现“ java.io.IOException:流关闭”的异常。

<camelContext id="template" useMDCLogging="true" xmlns="http://camel.apache.org/schema/spring">
    <camel:contextScan/>
    <camel:template id="templatePublish" camelContextId="template"/>
</camelContext>

在骆驼上下文xml文件中打开流缓存。 有什么建议我可能会错过吗?

0 个答案:

没有答案
相关问题