骆驼记录对身体内容的影响吗?

h__*_*h__ 2 apache-camel

在调试过程中的某些时候,通过系统的信息我被迫观察进入系统的XML格式的数据.为此,我添加了用于记录XML内容的附加行,并且XML内容显示在日志中.

此时,系统开始产生将XML内容封送到XML对象的问题.

org.apache.camel.TypeConversionException: Error during type conversion from type: org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache to the required type: com.company.product.customer.generated.XML with value org.apache.camel.

我认为系统中出现了一些新问题,甚至没有想到引入日志字段会引起一些麻烦.经过几个小时的战斗后,我决定删除日志行,它又开始无缝地工作了.

日志标记对正文消息有影响吗?为什么会这样?

<post uri="/requestXml"
    type="com.company.product.customer.generated.XML"
    outType="java.lang.String">
    <description>Request</description>

    <route>
        <to uri="bean:authenticationService?method=checkUser"/> 
        <!--log loggingLevel="INFO" message="Incomming XML ${body}"/-->
        <to uri="bean:messageTranslator?method=XMLRequestToConfiguration"/>
Run Code Online (Sandbox Code Playgroud)

lts*_*las 9

这与您只能读取一次流的事实有关.

虽然出于性能原因,流类型(如StreamSource,InputStream和Reader)通常用于消息传递,但它们也有一个重要缺点:它们只能读取一次.为了能够多次处理消息内容,需要缓存流.

您必须在上下文级别启用流缓存,如下所示:

<camelContext streamCache="true"> 
Run Code Online (Sandbox Code Playgroud)

有更多可用选项(例如,在路由级别启用它).在此处查看所有可用选项. http://camel.apache.org/stream-caching.html