It works with below sample codes by using aggregate: List<Bson> aggregate = Arrays.asList(Aggregates.match(Filters.gt("fieldname", value))); exchange.getIn().setHeader(MongoDbConstants.SORT_BY, Sorts.ascending("fieldname")); exchange.getIn().setHeader(MongoDbConstants.ALLOW_DISK_USE, true); exchange.getIn().setHeader(MongoDbConstants.BATCH_SIZE, 100); exchange.getIn().setBody(aggregate); Thank you, On Wednesday, September 30, 2020, 03:26:34 PM EDT, Jan Bednář <m...@janbednar.eu> wrote: Hi, allowDiskUse have been dedicated exclusively for aggregation. Support for this flag for find operations have been added to MongoDB Server recently with version 4.3.1. You need to rewrite findAll to aggragation - it is quite simple. I have logged https://issues.apache.org/jira/projects/CAMEL/issues/CAMEL-15604 , but you would need to use aggregation anyway if using MongoDB Server < 4.3.1
https://camel.apache.org/components/latest/mongodb-component.html#_aggregate https://jira.mongodb.org/browse/SERVER-43683 Dne 30.9.2020 v 20:28 Site Register napsal(a): > Hi all, > I got below error message when I was trying to sort on huge mongodb > collection data even I turn on allowDiskUse to true. Any suggestions? > "Query failed with error code 292 and error message 'Executor error during > find command :: caused by :: Sort exceeded memory limit of 104857600 bytes, > but did not opt in to external sorting.' on server" > > from("vm:fetchMongoDB") .process("ServiceProcessor") >.setHeader(MongoDbConstants.ALLOW_DISK_USE, constant(true)) > .setHeader(MongoDbConstants.SORT_BY, constant(Sorts.ascending("orderId"))) >.setHeader(MongoDbConstants.BATCH_SIZE, constant(100)) >.to("mongodb:mongoBean?database=mongoDb&collection=collectionName&operation=findAll") > > Thank you,