Apache的骆驼截取 - 捕获输出。 [英] Apache Camel Intercept - Capture Output.
问题描述
我在尝试使用Apache的骆驼拦截在spring.xml文件以捕获传入的请求和传出的响应,如:
I am attempting to use Apache Camel Interceptor in the spring.xml file to capture incoming requests and outgoing responses, like this:
<bean id="InterceptProcessor" class="CaptureProcessor"/>
<camel:camelContext id="camel">
<camel:jmxAgent id="agent" disabled="true" />
<camel:intercept>
<camel:process ref="InterceptProcessor"></camel:process>
</camel:intercept>
<camel:route id="Resource.rConnect.rconnect" autoStartup="false">
<camel:from
uri="cxfjetty:${Resource.rConnect.rconnect.baseUrl}?urlTemplateRef=#URLTemplateRef.Resource.rConnect.rconnect&
convertAttachments=true" />
<camel:to
uri="sonicesb://Process/rConnect?bindingStrategy=#ExposeBindingStrategy.Resource.rConnect.rconnect&headerFilterStrategy=#ExposeHeaderFilterStrategy.Resource.rConnect.rconnect&esbConfig=#ExposeEsbConfig.Resource.rConnect.rconnect" />
</camel:route>
<camel:route autoStartup="false">
<camel:from
uri="directsonicesb:Resource.rConnect.rconnect?bindingStrategy=#InvokeBindingStrategy.Resource.rConnect.rconnect&headerFilterStrategy=#InvokeHeaderFilterStrategy.Resource.rConnect.rconnect&uriTemplate=#URITemplate.Resource.rConnect.rconnect" />
<camel:to uri="sonicesb://Process/rConnect" />
</camel:route>
</camel:camelContext>
这个文章。
但CaptureProcessor仅在输入周期调用一次。
But the "CaptureProcessor" is only called once on the input cycle.
我怎样才能使它捕获输出呢?
How can I make it capture the Output as well?
推荐答案
按照骆驼DOC ,这是不可能的拦截
:
什么情况是,交易所在每一个加工步骤之前截获的,这意味着它会在
What happens is that the Exchange is intercepted before each processing step, that means that it will be intercepted before
因此,这是不可能拦截强>每个步骤之后的处理的。然而,有一个开放的吉拉票这一要求: CAMEL-6901
Thus, it is not possible to intercept the processing after each step. However, there's an open Jira ticket for this requirement: CAMEL-6901
另外,你可以使用 onCompletion
就是像一个可以为每个路由或全球整个骆驼上下文定义完成回调后:
Alternatively, you may use onCompletion
that is like an after completion callback which can be defined for each route or globally for the whole Camel context:
<onCompletion>
<log message="${body}" />
</onCompletion>
查看骆驼文档关于这种可能性的更多信息。
See the Camel docs for more information about this possibility.
这篇关于Apache的骆驼截取 - 捕获输出。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!