-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: Change Streams
-
None
-
(copied to CRM)
-
None
-
Java Drivers
-
None
-
None
-
None
-
None
-
None
-
None
I'm using tailable change stream cursors and want to exit the execution as soon as I've traversed all documents. Currently, I don't see a direct way to detect end of stream with Java API. By my observations:
- hasNext() blocks the thread until there is an dcoument to return, then returns true. It appears to be impossible for it to return anything but true.
- next() blocks the thread until a new document is available.
- tryNext() returns null without any indication on the cause. It may be due to exhausting the change stream, may be due to any other reason it couldn't fetch a document within timeout window.
Request:
Implement a method that conclusively and reliably tells when the change stream is exhausted.
Library versions:
org.mongodb:mongodb-driver-core:5.4.0
org.mongodb:mongodb-driver-legacy:5.4.0
org.mongodb:mongodb-driver-sync:5.4.0