Last active
September 1, 2019 02:18
-
-
Save eduardorost/ecbf170f6f5bee6320bec6ba052e9dc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val client = MongoClient.apply("mongodb.uri") | |
val database = client.getDatabase("mongodb.database") | |
val collection = database.getCollection("mongodb.collection") | |
collection.watch() | |
.fullDocument(FullDocument.UPDATE_LOOKUP) | |
.subscribe(new Observer[ChangeStreamDocument[Document]] { | |
override def onNext(changeDocument: ChangeStreamDocument[Document]): Unit = process(changeDocument) | |
override def onError(e: Throwable): Unit = println(s"Error: $e") | |
override def onComplete(): Unit = println("Completed") | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment