Java 为什么Camel MongoDB组件会在writeResultAsHeader=true的情况下更改主体
我正在使用Camel 2.10.4将文档保存到Mongo 2.10.1。作为Mongo端点配置的一部分,我指定 writeResultAsHeader=true }) 日志输出Java 为什么Camel MongoDB组件会在writeResultAsHeader=true的情况下更改主体,java,mongodb,apache-camel,Java,Mongodb,Apache Camel,我正在使用Camel 2.10.4将文档保存到Mongo 2.10.1。作为Mongo端点配置的一部分,我指定 writeResultAsHeader=true }) 日志输出 10:57:14 [INFO ]SpringCamelContext: Apache Camel 2.10.4 (CamelContext: camel-1) started in 0.281 seconds 10:57:14 [INFO ]testMongoSave: Before persist headers =
10:57:14 [INFO ]SpringCamelContext: Apache Camel 2.10.4 (CamelContext: camel-1) started in 0.281 seconds
10:57:14 [INFO ]testMongoSave: Before persist headers = {breadcrumbId=ID-saket-kumar-lmuk-local-34130-1385722634064-0-1}
10:57:14 [INFO ]testMongoSave: Before persist body = { "name" : "Saket"}
10:57:14 [WARN ]CamelMongoDBTest: In Header { "serverUsed" : "localhost/127.0.0.1:27017" , "n" : 0 , "connectionId" : 154 , "waited" : 37 , "err" : null , "ok" : 1.0}
10:57:14 [WARN ]CamelMongoDBTest: In Body { "serverUsed" : "localhost/127.0.0.1:27017" , "n" : 0 , "connectionId" : 154 , "waited" : 37 , "err" : null , "ok" : 1.0}
10:57:14 [WARN ]CamelMongoDBTest: Out Body No OUT
10:57:14 [INFO ]testMongoSave: After persist headers = {CamelMongoWriteResult={ "serverUsed" : "localhost/127.0.0.1:27017" , "n" : 0 , "connectionId" : 154 , "waited" : 37 , "err" : null , "ok" : 1.0}, breadcrumbId=ID-saket-kumar-lmuk-local-34130-1385722634064-0-1}
10:57:14 [INFO ]testMongoSave: After persist body = { "serverUsed" : "localhost/127.0.0.1:27017" , "n" : 0 , "connectionId" : 154 , "waited" : 37 , "err" : null , "ok" : 1.0}
我已经查看了Camel源代码,我认为可能存在一个bug(最后一行),我们在更新主体时没有检查writeResultAsHeader标志
// we always return the WriteResult, because whether the getLastError was called or not, the user will have the means to call it or
// obtain the cached CommandResult
processAndTransferWriteResult(result, exchange);
resultMessage.setBody(result);
我看到了另一个问题,但问题略有不同
有人遇到过同样的问题吗?或者我的用法不正确?选项WriteResultAsHeader中的WriteResult是Mongo在写入操作时返回的com.mongodb.WriteResult。它不是指写入操作结果(如find)。你可以在mongo呼叫前保存尸体,然后我想恢复是post
// we always return the WriteResult, because whether the getLastError was called or not, the user will have the means to call it or
// obtain the cached CommandResult
processAndTransferWriteResult(result, exchange);
resultMessage.setBody(result);