使用 onException 时,我无法让它共享工作单元。我确实需要使用多播和拆分器。到目前为止,我已经尝试过诸如 useOriginalMessage 等,但无法成功。
onException(Exception.class)
.handled(Boolean.TRUE)
.process(XXX)
.marshal()
.jacksonxml()
.convertBodyTo(String.class)
.removeHeader(XXXX)
.end();
from(RouteDefinition.XXX)
.id("XXX")
.unmarshal().jacksonxml(XXX.class)
.to("bean-validator://x")
.setHeader(XXXS, constant(XXX.class))
.setProperty(ApplicationParam.REQUEST_BODY, body())
.bean(xxxx, "XXX")
.setHeader(Exchange.HTTP_METHOD, constant(HttpMethod.POST))
.setHeader(Exchange.CONTENT_TYPE, constant(MediaType.APPLICATION_JSON))
.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, constant(XXX.class))
.to(restUri(jaxrsEndpoint, uri))
.removeHeader(Header.HEADER_LIST)
.bean(xxxx, "responseBeanXX")
.marshal().jacksonxml();
流程;Apache CXF -> JAXRS-> 异常 -> OnException -> 处理器 -> 响应正文