Unable to retrieve more than one object from Apache Camel MongoDb component












2















I have the following excerpt of code:



@Component
public class RetrievalAllFromDbRoute extends RouteBuilder{
public void configure() throws Exception {
this.from("direct:allObjects").routeId("retrieveAllObjectsFromDB")
.setHeader("CamelMongoDbBatchSize", constant(50))
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
DBObject fieldFilter = BasicDBObjectBuilder.start().add("_id", 1).get();
exchange.getMessage().setHeader(MongoDbConstants.FIELDS_FILTER, fieldFilter);
}
})
.to("mongodb:mongoClient?database="+mongoDbName +"&collection=myObjectCollection&operation=findAll&outputType=DBCursor")
.split(body())
.streaming()
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
JsonNode idNode = UtilMethods.convertStringToJson(exchange.getMessage().getBody().toString());
exchange.getMessage().setBody(idNode.get("_id").asText());
System.out.println("n Extracted id["+exchange.getMessage().getBody().toString()+"] from db n");
}
});
}
}


However I am only getting a single output.
Setting a break point and querying of the db in the first prcessor reveals that there are over 300 objects in the database, so I don't understand why I am only getting 1 object.



EDIT:

My maven POM dependency:



<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb</artifactId>
<version>2.22.0</version>
</dependency>


working with a MongoDB 3.6 database










share|improve this question




















  • 1





    Strange, this should work according this gist. Could you confirm, you are using camel-mongo component and not camel-mongodb3 component? Which version of Camel and component you are using?

    – Bedla
    Nov 25 '18 at 13:28











  • @Bedla I'm using the camel-mongodb component from the 2.22.0 maven plugin. I am however switching to the camel-mongodb3 version now to see if this makes a difference since the underlying db is mongo3.6

    – Dark Star1
    Nov 26 '18 at 14:59













  • During migration keep in mind, that outputType DBCursor is renamed to MongoIterable in camel-mongo3. Source here

    – Bedla
    Nov 26 '18 at 19:59













  • @Bedla Nothing has changed. The iterable still only returns one document

    – Dark Star1
    Nov 27 '18 at 10:11
















2















I have the following excerpt of code:



@Component
public class RetrievalAllFromDbRoute extends RouteBuilder{
public void configure() throws Exception {
this.from("direct:allObjects").routeId("retrieveAllObjectsFromDB")
.setHeader("CamelMongoDbBatchSize", constant(50))
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
DBObject fieldFilter = BasicDBObjectBuilder.start().add("_id", 1).get();
exchange.getMessage().setHeader(MongoDbConstants.FIELDS_FILTER, fieldFilter);
}
})
.to("mongodb:mongoClient?database="+mongoDbName +"&collection=myObjectCollection&operation=findAll&outputType=DBCursor")
.split(body())
.streaming()
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
JsonNode idNode = UtilMethods.convertStringToJson(exchange.getMessage().getBody().toString());
exchange.getMessage().setBody(idNode.get("_id").asText());
System.out.println("n Extracted id["+exchange.getMessage().getBody().toString()+"] from db n");
}
});
}
}


However I am only getting a single output.
Setting a break point and querying of the db in the first prcessor reveals that there are over 300 objects in the database, so I don't understand why I am only getting 1 object.



EDIT:

My maven POM dependency:



<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb</artifactId>
<version>2.22.0</version>
</dependency>


working with a MongoDB 3.6 database










share|improve this question




















  • 1





    Strange, this should work according this gist. Could you confirm, you are using camel-mongo component and not camel-mongodb3 component? Which version of Camel and component you are using?

    – Bedla
    Nov 25 '18 at 13:28











  • @Bedla I'm using the camel-mongodb component from the 2.22.0 maven plugin. I am however switching to the camel-mongodb3 version now to see if this makes a difference since the underlying db is mongo3.6

    – Dark Star1
    Nov 26 '18 at 14:59













  • During migration keep in mind, that outputType DBCursor is renamed to MongoIterable in camel-mongo3. Source here

    – Bedla
    Nov 26 '18 at 19:59













  • @Bedla Nothing has changed. The iterable still only returns one document

    – Dark Star1
    Nov 27 '18 at 10:11














2












2








2








I have the following excerpt of code:



@Component
public class RetrievalAllFromDbRoute extends RouteBuilder{
public void configure() throws Exception {
this.from("direct:allObjects").routeId("retrieveAllObjectsFromDB")
.setHeader("CamelMongoDbBatchSize", constant(50))
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
DBObject fieldFilter = BasicDBObjectBuilder.start().add("_id", 1).get();
exchange.getMessage().setHeader(MongoDbConstants.FIELDS_FILTER, fieldFilter);
}
})
.to("mongodb:mongoClient?database="+mongoDbName +"&collection=myObjectCollection&operation=findAll&outputType=DBCursor")
.split(body())
.streaming()
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
JsonNode idNode = UtilMethods.convertStringToJson(exchange.getMessage().getBody().toString());
exchange.getMessage().setBody(idNode.get("_id").asText());
System.out.println("n Extracted id["+exchange.getMessage().getBody().toString()+"] from db n");
}
});
}
}


However I am only getting a single output.
Setting a break point and querying of the db in the first prcessor reveals that there are over 300 objects in the database, so I don't understand why I am only getting 1 object.



EDIT:

My maven POM dependency:



<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb</artifactId>
<version>2.22.0</version>
</dependency>


working with a MongoDB 3.6 database










share|improve this question
















I have the following excerpt of code:



@Component
public class RetrievalAllFromDbRoute extends RouteBuilder{
public void configure() throws Exception {
this.from("direct:allObjects").routeId("retrieveAllObjectsFromDB")
.setHeader("CamelMongoDbBatchSize", constant(50))
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
DBObject fieldFilter = BasicDBObjectBuilder.start().add("_id", 1).get();
exchange.getMessage().setHeader(MongoDbConstants.FIELDS_FILTER, fieldFilter);
}
})
.to("mongodb:mongoClient?database="+mongoDbName +"&collection=myObjectCollection&operation=findAll&outputType=DBCursor")
.split(body())
.streaming()
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
JsonNode idNode = UtilMethods.convertStringToJson(exchange.getMessage().getBody().toString());
exchange.getMessage().setBody(idNode.get("_id").asText());
System.out.println("n Extracted id["+exchange.getMessage().getBody().toString()+"] from db n");
}
});
}
}


However I am only getting a single output.
Setting a break point and querying of the db in the first prcessor reveals that there are over 300 objects in the database, so I don't understand why I am only getting 1 object.



EDIT:

My maven POM dependency:



<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb</artifactId>
<version>2.22.0</version>
</dependency>


working with a MongoDB 3.6 database







mongodb apache-camel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 15:48







Dark Star1

















asked Nov 25 '18 at 12:52









Dark Star1Dark Star1

3,023115798




3,023115798








  • 1





    Strange, this should work according this gist. Could you confirm, you are using camel-mongo component and not camel-mongodb3 component? Which version of Camel and component you are using?

    – Bedla
    Nov 25 '18 at 13:28











  • @Bedla I'm using the camel-mongodb component from the 2.22.0 maven plugin. I am however switching to the camel-mongodb3 version now to see if this makes a difference since the underlying db is mongo3.6

    – Dark Star1
    Nov 26 '18 at 14:59













  • During migration keep in mind, that outputType DBCursor is renamed to MongoIterable in camel-mongo3. Source here

    – Bedla
    Nov 26 '18 at 19:59













  • @Bedla Nothing has changed. The iterable still only returns one document

    – Dark Star1
    Nov 27 '18 at 10:11














  • 1





    Strange, this should work according this gist. Could you confirm, you are using camel-mongo component and not camel-mongodb3 component? Which version of Camel and component you are using?

    – Bedla
    Nov 25 '18 at 13:28











  • @Bedla I'm using the camel-mongodb component from the 2.22.0 maven plugin. I am however switching to the camel-mongodb3 version now to see if this makes a difference since the underlying db is mongo3.6

    – Dark Star1
    Nov 26 '18 at 14:59













  • During migration keep in mind, that outputType DBCursor is renamed to MongoIterable in camel-mongo3. Source here

    – Bedla
    Nov 26 '18 at 19:59













  • @Bedla Nothing has changed. The iterable still only returns one document

    – Dark Star1
    Nov 27 '18 at 10:11








1




1





Strange, this should work according this gist. Could you confirm, you are using camel-mongo component and not camel-mongodb3 component? Which version of Camel and component you are using?

– Bedla
Nov 25 '18 at 13:28





Strange, this should work according this gist. Could you confirm, you are using camel-mongo component and not camel-mongodb3 component? Which version of Camel and component you are using?

– Bedla
Nov 25 '18 at 13:28













@Bedla I'm using the camel-mongodb component from the 2.22.0 maven plugin. I am however switching to the camel-mongodb3 version now to see if this makes a difference since the underlying db is mongo3.6

– Dark Star1
Nov 26 '18 at 14:59







@Bedla I'm using the camel-mongodb component from the 2.22.0 maven plugin. I am however switching to the camel-mongodb3 version now to see if this makes a difference since the underlying db is mongo3.6

– Dark Star1
Nov 26 '18 at 14:59















During migration keep in mind, that outputType DBCursor is renamed to MongoIterable in camel-mongo3. Source here

– Bedla
Nov 26 '18 at 19:59







During migration keep in mind, that outputType DBCursor is renamed to MongoIterable in camel-mongo3. Source here

– Bedla
Nov 26 '18 at 19:59















@Bedla Nothing has changed. The iterable still only returns one document

– Dark Star1
Nov 27 '18 at 10:11





@Bedla Nothing has changed. The iterable still only returns one document

– Dark Star1
Nov 27 '18 at 10:11












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467621%2funable-to-retrieve-more-than-one-object-from-apache-camel-mongodb-component%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467621%2funable-to-retrieve-more-than-one-object-from-apache-camel-mongodb-component%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Tonle Sap (See)

I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

Guatemaltekische Davis-Cup-Mannschaft