Github user pvillard31 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1948#discussion_r124570752
  
    --- Diff: 
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java
 ---
    @@ -158,17 +191,43 @@ public void onTrigger(final ProcessContext context, 
final ProcessSession session
                 final MongoCursor<Document> cursor = it.iterator();
                 try {
                     FlowFile flowFile = null;
    -                while (cursor.hasNext()) {
    -                    flowFile = session.create();
    -                    flowFile = session.write(flowFile, new 
OutputStreamCallback() {
    -                        @Override
    -                        public void process(OutputStream out) throws 
IOException {
    -                            IOUtils.write(cursor.next().toJson(), out);
    +                if (context.getProperty(RESULTS_PER_FLOWFILE).isSet()) {
    +                    int ceiling = 
context.getProperty(RESULTS_PER_FLOWFILE).asInteger();
    +                    List<Document> batch = new ArrayList<>();
    +
    +                    while (cursor.hasNext()) {
    +                        batch.add(cursor.next());
    +                        if (batch.size() == ceiling) {
    +                            try {
    +                                getLogger().info("Writing batch...");
    --- End diff --
    
    I would not log this at info level but would use debug instead (otherwise, 
it could be really verbose when the processor is used at a high rate).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to