我正在开发的应用程序是一个中间件应用程序,它允许在大量应用程序(主要是SOAP服务)之间进行路由。由于Camel自动生成的日志,我们遇到了饱和。
使用新的拦截器减少了日志容量。但是,如果在当前路由内调用服务,我得到的只是来自SendToEndpoint拦截器的请求体。
由于应用程序中的所有服务调用都是以这种方式进行的,因此我不能更改当前路由。
旧的拦截器:
getContext().setTracing(true); // <--- trace every step of all routes
interceptFrom().to("log:example");
configureRoutes() {
// route logic
}新的拦截器:
getContext().setTracing(false);
interceptFrom("cxf:*").to("log:example");
interceptSendToEndpoint("cxf:*").to("log:example");
configureRoutes() {
// route logic
}路由示例:
from("scheduler endpoint")
.to("DAO method to find the case from database")
.process(//First processor to call the SOAP service)
.to("SOAP endpoint")
.convertBodyTo(SOAP ResponseBody.class) <-- convert the MessageContentsList to SOAP response body generated from the WSDL
.process(//Second processor to check if the response code is OK in the SOAP response body);如何实现允许记录SOAP响应体的拦截器?
谢谢你的帮助。
发布于 2019-02-06 07:15:04
我不喜欢对这只海豚使用拦截器,我建议你使用EventNotifier接口,你只需要在camel上下文中声明它为一个bean,并覆盖notify方法。
请参阅:https://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/spi/EventNotifier.html
下面是一个用法示例:http://camel.apache.org/eventnotifier-to-log-details-about-all-sent-exchanges.html
注意: Camel有一些你可以使用的事件,比如: CamelContextCreated,ExchangeCreatedEvent,ExchangeSendingEvent,ExchangeSentEvent,ExchangeCompletedEvent,ExchangeFailedEvent等等。
https://stackoverflow.com/questions/54404841
复制相似问题