Package com.mongodb.client
Interface MongoChangeStreamCursor<TResult>
-
- Type Parameters:
TResult
- The type of documents the cursor contains
- All Superinterfaces:
AutoCloseable
,Closeable
,Iterator<TResult>
,MongoCursor<TResult>
public interface MongoChangeStreamCursor<TResult> extends MongoCursor<TResult>
The Mongo Cursor interface for change streams implementing the iterator protocol.An application should ensure that a cursor is closed in all circumstances, e.g. using a try-with-resources statement:
try (MongoChangeStreamCursor<Document> cursor = collection.find().cursor()) { while (cursor.hasNext()) { System.out.println(cursor.next()); } }
- Since:
- 3.11
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BsonDocument
getResumeToken()
Returns the resume token.-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Methods inherited from interface com.mongodb.client.MongoCursor
close, getServerAddress, getServerCursor, hasNext, next, tryNext
-
-
-
-
Method Detail
-
getResumeToken
@Nullable BsonDocument getResumeToken()
Returns the resume token. If a batch has been iterated to the last change stream document in the batch and a postBatchResumeToken is included in the document, the postBatchResumeToken will be returned. Otherwise, the resume token contained in the last change stream document will be returned.- Returns:
- the resume token, which can be null if the cursor has either not been iterated yet, or the cursor is closed.
-
-