From cea4317b4484ed4f17ddf98ea864d27d439a3956 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 2 Nov 2017 08:56:09 +0100 Subject: [PATCH 1/3] DATAMONGO-1818 - Prepare issue branch. --- pom.xml | 2 +- spring-data-mongodb-benchmarks/pom.xml | 2 +- spring-data-mongodb-cross-store/pom.xml | 4 ++-- spring-data-mongodb-distribution/pom.xml | 2 +- spring-data-mongodb/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 25a7ba08f5..bf0988b2c8 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-mongodb-parent - 2.1.0.BUILD-SNAPSHOT + 2.1.0.DATAMONGO-1818-SNAPSHOT pom Spring Data MongoDB diff --git a/spring-data-mongodb-benchmarks/pom.xml b/spring-data-mongodb-benchmarks/pom.xml index 9baccaa905..1b76435c91 100644 --- a/spring-data-mongodb-benchmarks/pom.xml +++ b/spring-data-mongodb-benchmarks/pom.xml @@ -7,7 +7,7 @@ org.springframework.data spring-data-mongodb-parent - 2.1.0.BUILD-SNAPSHOT + 2.1.0.DATAMONGO-1818-SNAPSHOT ../pom.xml diff --git a/spring-data-mongodb-cross-store/pom.xml b/spring-data-mongodb-cross-store/pom.xml index 8ba393d38b..8decf290da 100644 --- a/spring-data-mongodb-cross-store/pom.xml +++ b/spring-data-mongodb-cross-store/pom.xml @@ -6,7 +6,7 @@ org.springframework.data spring-data-mongodb-parent - 2.1.0.BUILD-SNAPSHOT + 2.1.0.DATAMONGO-1818-SNAPSHOT ../pom.xml @@ -49,7 +49,7 @@ org.springframework.data spring-data-mongodb - 2.1.0.BUILD-SNAPSHOT + 2.1.0.DATAMONGO-1818-SNAPSHOT diff --git a/spring-data-mongodb-distribution/pom.xml b/spring-data-mongodb-distribution/pom.xml index e5c865ea08..6978a0cef0 100644 --- a/spring-data-mongodb-distribution/pom.xml +++ b/spring-data-mongodb-distribution/pom.xml @@ -13,7 +13,7 @@ org.springframework.data spring-data-mongodb-parent - 2.1.0.BUILD-SNAPSHOT + 2.1.0.DATAMONGO-1818-SNAPSHOT ../pom.xml diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml index 41b711f7c8..5c8abec0bd 100644 --- a/spring-data-mongodb/pom.xml +++ b/spring-data-mongodb/pom.xml @@ -11,7 +11,7 @@ org.springframework.data spring-data-mongodb-parent - 2.1.0.BUILD-SNAPSHOT + 2.1.0.DATAMONGO-1818-SNAPSHOT ../pom.xml From fafa4a00fda178d708ec4f362f1147497f677597 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 2 Nov 2017 08:55:32 +0100 Subject: [PATCH 2/3] DATAMONGO-1818 - Reword tailable cursors documentation. Fix reference to Tailable annotation. Slightly reword documentation. --- .../asciidoc/reference/reactive-mongo-repositories.adoc | 8 +++++--- src/main/asciidoc/reference/reactive-mongodb.adoc | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/asciidoc/reference/reactive-mongo-repositories.adoc b/src/main/asciidoc/reference/reactive-mongo-repositories.adoc index 386a36406b..c334f07d20 100644 --- a/src/main/asciidoc/reference/reactive-mongo-repositories.adoc +++ b/src/main/asciidoc/reference/reactive-mongo-repositories.adoc @@ -190,9 +190,11 @@ public interface PersonRepository extends ReactiveMongoRepository System.out.println(person)). // … -// Later: Dispose the stream +// Later: Dispose the subscription to close the stream subscription.dispose(); ---- - [[mongo.reactive.executioncallback]] == Execution callbacks From b67df80db5154236345bf7801998a27ad80873cf Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 21 Nov 2017 15:23:40 +0100 Subject: [PATCH 3/3] DATAMONGO-1818 - Polishing. Move overlapping/duplicate documentation into one place. --- .../reactive-mongo-repositories.adoc | 25 +++++++++++++++++-- .../asciidoc/reference/reactive-mongodb.adoc | 19 -------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/main/asciidoc/reference/reactive-mongo-repositories.adoc b/src/main/asciidoc/reference/reactive-mongo-repositories.adoc index c334f07d20..a9df36e076 100644 --- a/src/main/asciidoc/reference/reactive-mongo-repositories.adoc +++ b/src/main/asciidoc/reference/reactive-mongo-repositories.adoc @@ -190,12 +190,30 @@ public interface PersonRepository extends ReactiveMongoRepository stream = template.tail(query(where("name").is("Joe")), Person.class); + +Disposable subscription = stream.doOnNext(person -> System.out.println(person)).subscribe(); + +// … + +// Later: Dispose the subscription to close the stream +subscription.dispose(); +---- +==== + +Spring Data MongoDB Reactive repositories support infinite streams by annotating a query method with `@Tailable`. This works for methods returning `Flux` and other reactive types capable of emitting multiple elements. + +.Infinite Stream queries with ReactiveMongoRepository +==== [source,java] ---- @@ -215,3 +233,6 @@ Disposable subscription = stream.doOnNext(System.out::println).subscribe(); // Later: Dispose the subscription to close the stream subscription.dispose(); ---- +==== + +TIP: Capped collections can be created via `MongoOperations.createCollection`. Just provide the required `CollectionOptions.empty().capped()...` diff --git a/src/main/asciidoc/reference/reactive-mongodb.adoc b/src/main/asciidoc/reference/reactive-mongodb.adoc index 34a6208525..cd59683db0 100644 --- a/src/main/asciidoc/reference/reactive-mongodb.adoc +++ b/src/main/asciidoc/reference/reactive-mongodb.adoc @@ -457,25 +457,6 @@ NOTE: This example is meant to show the use of save, update and remove operation The query syntax used in the example is explained in more detail in the section <>. Additional documentation can be found in <> section. -[[mongo.reactive.tailcursors]] -== Infinite Streams - -By default, MongoDB will automatically close a cursor when the client exhausts all results supplied by the cursor. Closing a cursor on exhaustion turns a stream into a finite stream. For capped collections, you may use a https://docs.mongodb.com/manual/core/tailable-cursors/[Tailable Cursor] that remains open after the client consumes all initially returned data. Using tailable cursors with a reactive data types allows construction of infinite streams. A tailable cursor remains open until it's closed externally. It emits data as new documents arrive in a capped collection. - -Tailable cursors may become dead, or invalid, if either the query returns no match or the cursor returns the document at the "end" of the collection and then the application deletes that document. - -[source,java] ----- -Flux stream = template.tail(query(where("name").is("Joe")), Person.class); - -Disposable subscription = stream.doOnNext(person -> System.out.println(person)).subscribe(); - -// … - -// Later: Dispose the subscription to close the stream -subscription.dispose(); ----- - [[mongo.reactive.executioncallback]] == Execution callbacks