You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "bipin.sutariya" <bi...@gmail.com> on 2013/11/08 20:11:51 UTC

MongoDB exchange Out Body is null, using Apache Camel

I am trying to save some data in MongoDB using apache Camel. Following is my
code 
 
from("direct:saveData") 
.process(dataSaveRequestProcessor) 
.streamCaching() 
.to("mongodb:emailDB?database=myDB&collection=myData&operation=save&writeConcern=safe&writeResultAsHeader=true")  
               .process(dataSaveResponseProcessor); 
 
Now issue is in MongoDB record is saved, but it is not returned back to my
Response Processor. I need _id that is generated in MongoDB to pass to
another Route. 
 
 
Following is System.out in Response Processor 
 
===============> OUT BODY : null 
===============> OUT BODY HEADER: {} 
===============> IN BODY : { "serverUsed" : "/127.0.0.1:27017" , "n" : 0 ,
"connectionId" : 22 , "err" :  null  , "ok" : 1.0} 
===============> IN BODY HEADER : {CamelMongoWriteResult={ "serverUsed" :
"/127.0.0.1:27017" , "n" : 0 , "connectionId" : 22 , "err" :  null  ,"ok" :
1.0}, CamelMongoDbLastError={ "serverUsed" : "/127.0.0.1:27017" , "n" : 0 ,
"connectionId" : 22 , "err" : null , "ok" : 1.0}} 
 
 
Can anybody pointed out where I am making mistake. Why there is not _id in
exchange.getIN().getBody() 
 
Thank you in Advance



--
View this message in context: http://camel.465427.n5.nabble.com/MongoDB-exchange-Out-Body-is-null-using-Apache-Camel-tp5742888.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: MongoDB exchange Out Body is null, using Apache Camel

Posted by "bipin.sutariya" <bi...@gmail.com>.
@Raul,

I will use user@ foe new query. I am using camel 2.12.1.

And I am using writeResultAsHeader in my endpoint 

mongodb:emailDB?database=myDB&collection=myData&operation=save&writeConcern=safe&writeResultAsHeader=true

But still I am not getting inserted result neither in header nor in body.

I really appreciate any help on this.





--
View this message in context: http://camel.465427.n5.nabble.com/MongoDB-exchange-Out-Body-is-null-using-Apache-Camel-tp5742888p5743042.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: MongoDB exchange Out Body is null, using Apache Camel

Posted by Raul Kripalani <ra...@evosent.com>.
If you're using Camel >= 2.10.3 or 2.11, enable the writeResultAsHeader
endpoint option.

In the future, please use the users@ forum for such queries. And please
remember to always indicate what version of Camel you're running on.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Fri, Nov 8, 2013 at 7:11 PM, bipin.sutariya <bi...@gmail.com>wrote:

> I am trying to save some data in MongoDB using apache Camel. Following is
> my
> code
>
> from("direct:saveData")
> .process(dataSaveRequestProcessor)
> .streamCaching()
>
> .to("mongodb:emailDB?database=myDB&collection=myData&operation=save&writeConcern=safe&writeResultAsHeader=true")
>                .process(dataSaveResponseProcessor);
>
> Now issue is in MongoDB record is saved, but it is not returned back to my
> Response Processor. I need _id that is generated in MongoDB to pass to
> another Route.
>
>
> Following is System.out in Response Processor
>
> ===============> OUT BODY : null
> ===============> OUT BODY HEADER: {}
> ===============> IN BODY : { "serverUsed" : "/127.0.0.1:27017" , "n" : 0 ,
> "connectionId" : 22 , "err" :  null  , "ok" : 1.0}
> ===============> IN BODY HEADER : {CamelMongoWriteResult={ "serverUsed" :
> "/127.0.0.1:27017" , "n" : 0 , "connectionId" : 22 , "err" :  null  ,"ok"
> :
> 1.0}, CamelMongoDbLastError={ "serverUsed" : "/127.0.0.1:27017" , "n" : 0
> ,
> "connectionId" : 22 , "err" : null , "ok" : 1.0}}
>
>
> Can anybody pointed out where I am making mistake. Why there is not _id in
> exchange.getIN().getBody()
>
> Thank you in Advance
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/MongoDB-exchange-Out-Body-is-null-using-Apache-Camel-tp5742888.html
> Sent from the Camel Development mailing list archive at Nabble.com.

Re: MongoDB exchange Out Body is null, using Apache Camel

Posted by Raul Kripalani <ra...@evosent.com>.
If you're using Camel >= 2.10.3 or 2.11, enable the writeResultAsHeader
endpoint option.

In the future, please use the users@ forum for such queries. And please
remember to always indicate what version of Camel you're running on.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Fri, Nov 8, 2013 at 7:11 PM, bipin.sutariya <bi...@gmail.com>wrote:

> I am trying to save some data in MongoDB using apache Camel. Following is
> my
> code
>
> from("direct:saveData")
> .process(dataSaveRequestProcessor)
> .streamCaching()
>
> .to("mongodb:emailDB?database=myDB&collection=myData&operation=save&writeConcern=safe&writeResultAsHeader=true")
>                .process(dataSaveResponseProcessor);
>
> Now issue is in MongoDB record is saved, but it is not returned back to my
> Response Processor. I need _id that is generated in MongoDB to pass to
> another Route.
>
>
> Following is System.out in Response Processor
>
> ===============> OUT BODY : null
> ===============> OUT BODY HEADER: {}
> ===============> IN BODY : { "serverUsed" : "/127.0.0.1:27017" , "n" : 0 ,
> "connectionId" : 22 , "err" :  null  , "ok" : 1.0}
> ===============> IN BODY HEADER : {CamelMongoWriteResult={ "serverUsed" :
> "/127.0.0.1:27017" , "n" : 0 , "connectionId" : 22 , "err" :  null  ,"ok"
> :
> 1.0}, CamelMongoDbLastError={ "serverUsed" : "/127.0.0.1:27017" , "n" : 0
> ,
> "connectionId" : 22 , "err" : null , "ok" : 1.0}}
>
>
> Can anybody pointed out where I am making mistake. Why there is not _id in
> exchange.getIN().getBody()
>
> Thank you in Advance
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/MongoDB-exchange-Out-Body-is-null-using-Apache-Camel-tp5742888.html
> Sent from the Camel Development mailing list archive at Nabble.com.