Mongo Change Stream Cursor
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 use
statement:
collection.watch().cursor().use { c ->
while (c.hasNext()) {
println(c.next())
}
}
A com.mongodb.MongoOperationTimeoutException does not invalidate the MongoChangeStreamCursor, but is immediately propagated to the caller. Subsequent method calls will attempt to resume operation by establishing a new change stream on the server, without performing a getMore
request first.
If a com.mongodb.MongoOperationTimeoutException occurs before any events are received, it indicates that the server has timed out before it could finish processing the existing oplog. In such cases, it is recommended to close the current stream and recreate it with a higher timeout setting.
Parameters
The type of documents the cursor contains
Properties
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.