Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-1803

Add support for MongoDB 3.6 change streams

    Details

      Description

      MongoDB 3.6 introduces a new feature called change stream that emits all changes to a particular collection:

              MongoCollection<Document> collection = database.getCollection("documents");
              System.out.println("1. Initial document from the Change Stream:");
      
              // Create the change stream publisher.
              ChangeStreamPublisher<Document> publisher = collection.watch();
      
              // Get the resume token from the last document we saw in the previous change stream cursor.
              BsonDocument resumeToken = (ChangeStreamDocument).getResumeToken();
      
              // Pass the resume token to the resume after function to continue the change stream cursor.
              publisher = collection.watch().resumeAfter(resumeToken);
      

      Watch accepts an aggregation pipeline to filter/transform elements.

        Attachments

          Activity

            People

            • Assignee:
              mp911de Mark Paluch
              Reporter:
              mp911de Mark Paluch
              Last updater:
              Oliver Drotbohm
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: