Apache camel Camel json验证程序引发流关闭异常
我尝试根据模式验证json负载,并尝试使用“驼峰json验证器”。 下面是我如何配置它的Apache camel Camel json验证程序引发流关闭异常,apache-camel,Apache Camel,我尝试根据模式验证json负载,并尝试使用“驼峰json验证器”。 下面是我如何配置它的 public void configure() throws Exception { onException(CamelException.class, CamelExecutionException.class, Exception.class).handled(true).bean(WcaExceptionProcessor.class, "handleExceptio
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");
}
当代码运行时,如果FIELD长度超过maximim允许值,我希望出现验证异常。然而,我得到的异常是“java.io.IOException:streamclosed”
流缓存在camel上下文xml文件中打开。
有什么我可能缺少的建议吗?尝试打开流缓存,请参阅此常见问题解答:Hi Claus。我在配置xml的camel conetxt中打开了streamcaching。您使用的是什么版本的Camel?我使用的是Camel 2.22.0 Hanks,您是否能够提供一个复制器(示例项目),例如作为githhub上的项目,或者记录JIRA票证并随示例项目附上一个.zip文件。然后我们可以用它来更快地调查这个问题。
<camelContext id="template" useMDCLogging="true" xmlns="http://camel.apache.org/schema/spring">
<camel:contextScan/>
<camel:template id="templatePublish" camelContextId="template"/>
</camelContext>