Class NamespaceChangeStreamListener
- java.lang.Object
-
- com.mongodb.stitch.core.services.mongodb.remote.sync.internal.NamespaceChangeStreamListener
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class NamespaceChangeStreamListener extends Object implements Closeable
-
-
Method Summary
Modifier and Type Method Description void
close()
Map<BsonValue,CompactChangeEvent<BsonDocument>>
getEvents()
Returns the latest change events, and clears them from the change stream listener.CompactChangeEvent<BsonDocument>
getUnprocessedEventForDocumentId(BsonValue documentId)
If there is an unprocessed change event for a particular document ID, fetch it from the change stream listener, and remove it.boolean
isOpen()
Whether or not the current stream is currently open.void
start()
Opens the stream in a background thread.void
stop()
Stops the background stream thread.
-
-
-
Method Detail
-
start
public void start()
Opens the stream in a background thread.
-
stop
public void stop()
Stops the background stream thread.
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
isOpen
public boolean isOpen()
Whether or not the current stream is currently open.- Returns:
- true if open, false if not
-
getEvents
public Map<BsonValue,CompactChangeEvent<BsonDocument>> getEvents()
Returns the latest change events, and clears them from the change stream listener.- Returns:
- the latest change events.
-
getUnprocessedEventForDocumentId
@Nullable public CompactChangeEvent<BsonDocument> getUnprocessedEventForDocumentId(BsonValue documentId)
If there is an unprocessed change event for a particular document ID, fetch it from the change stream listener, and remove it. By reading the event here, we are assuming it will be processed by the consumer.- Returns:
- the latest unprocessed change event for the given document ID, or null if none exists.
-
-