Synchronization mechanism for Java Async Driver

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I'm using the 3.2.1 Async driver to do the following :

      ...
      
      while(InputIterator.hasNext()){
      
         MongoCollection.insertOne(document, new SingleResultCallback<Void>(){
          @Override
          public void onResult(Void v, Throwable t) {
              
          }
      });
      
      }
      ...
      
      MongoClient.close();
      

      The only issue is that MongoClient is being closed before all of the queued inserts are processed and I'm getting "Pool is closed". I cannot use CountDownLatch as I don't know the size of my InputIterator.

      Does the Async driver provide any synchronization mechanisms that we can use in this case ?

            Assignee:
            Unassigned
            Reporter:
            Abbass Marouni
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: