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