Interface ChangeStreamIterable<TResult>

    • Method Detail

      • cursor

        MongoChangeStreamCursor<ChangeStreamDocument<TResult>> cursor()
        Returns a cursor used for iterating over elements of type ChangeStreamDocument<TResult>. The cursor has a covariant return type to additionally provide a method to access the resume token in change stream batches.
        Specified by:
        cursor in interface MongoIterable<TResult>
        Returns:
        the change stream cursor
        Since:
        3.11
      • resumeAfter

        ChangeStreamIterable<TResult> resumeAfter(BsonDocument resumeToken)
        Sets the logical starting point for the new change stream.
        Parameters:
        resumeToken - the resume token
        Returns:
        this
      • maxAwaitTime

        ChangeStreamIterable<TResult> maxAwaitTime(long maxAwaitTime,
                                                   TimeUnit timeUnit)
        Sets the maximum await execution time on the server for this operation.
        Parameters:
        maxAwaitTime - the max await time. A zero value will be ignored, and indicates that the driver should respect the server's default value
        timeUnit - the time unit, which may not be null
        Returns:
        this
      • withDocumentClass

        <TDocument> MongoIterable<TDocument> withDocumentClass(Class<TDocument> clazz)
        Returns a MongoIterable containing the results of the change stream based on the document class provided.
        Type Parameters:
        TDocument - the result type
        Parameters:
        clazz - the class to use for the raw result.
        Returns:
        the new Mongo Iterable
      • startAtOperationTime

        ChangeStreamIterable<TResult> startAtOperationTime(BsonTimestamp startAtOperationTime)
        The change stream will only provide changes that occurred at or after the specified timestamp.

        Any command run against the server will return an operation time that can be used here.

        The default value is an operation time obtained from the server before the change stream was created.

        Parameters:
        startAtOperationTime - the start at operation time
        Returns:
        this
        Since:
        3.8
        MongoDB documentation
        reference/method/db.runCommand/
        Since server release
        4.0
      • startAfter

        ChangeStreamIterable<TResult> startAfter(BsonDocument startAfter)
        Similar to resumeAfter, this option takes a resume token and starts a new change stream returning the first notification after the token.

        This will allow users to watch collections that have been dropped and recreated or newly renamed collections without missing any notifications.

        Note: The server will report an error if both startAfter and resumeAfter are specified.

        Parameters:
        startAfter - the startAfter resumeToken
        Returns:
        this
        Since:
        3.11
        MongoDB documentation
        changeStreams/#change-stream-start-after
        Since server release
        4.2