title: MongoDB Change Stream reading data which are old updates
body: <p>I have created an application which reads mongo change stream for updates and inserts and then we take action on the changed data. Below is my code snippet</p>
  
  <pre><code>private void listenChangeStream() {
          Runnable changeListener = new Runnable() {
              @Override
              public void run() {
                  String fullDoc = null;
                  String updateInfo = null;
  
                  while (cursor.hasNext()) {
                      try {
                          ChangeStreamDocument&lt;Document&gt; next = cursor.next();
                          String id = next.getDocumentKey().getString("id").getValue();
                          LOGGER.debug("Change Stream recived:{}", next);
                          String operationType = next.getOperationType().getValue();
                          if ("insert".equals(operationType) || "replace".equals(operationType)) {
                                 fullDoc = next.getFullDocument().toString();
                              if (fullDoc.contains("image_info")) {
                                  kafkaProducer
                                          .pushOfflineProcessingData(new DataPackets(Id, OfflineProcessType.IMAGE));
                              }
                          } else if ("update".equals(operationType)) {
                                 updateInfo = next.getUpdateDescription().toString();
                              if (updateInfo.contains("image_info"))
                                  kafkaProducer
                                          .pushOfflineProcessingData(new DataPackets(Id, OfflineProcessType.IMAGE));
                          } 
  
                      } catch (Exception ex) {
                          LOGGER.info("Exception has come in cahnge listener::", ex);
                      }
                  }
  
              }
          };
          executor = Executors.newFixedThreadPool(1);
          executor.execute(changeListener);
  
      }
  
  private MongoCursor&lt;ChangeStreamDocument&lt;Document&gt;&gt; getCursor(MongoCollection&lt;Document&gt; supplierCollection, List&lt;Bson&gt; pipeline) {
          MongoCursor&lt;ChangeStreamDocument&lt;Document&gt;&gt; cursor;     
               cursor = supplierCollection.watch(pipeline).iterator();        
          return cursor;
      }
  </code></pre>
  
  <p>This is working fine.
  The problem which i am facing is when ever i start the server the change stream starts reading old committed changes . Which i do not want. I want after the deployment only the new updates should be picked by this.</p>
  
  <p>Can any one suggest how to do it?</p>