Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么Camel MongoDB组件会在writeResultAsHeader=true的情况下更改主体_Java_Mongodb_Apache Camel - Fatal编程技术网

Java 为什么Camel MongoDB组件会在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 =

我正在使用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 = {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);