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 diff --git a/src/main/asciidoc/reference/reactive-mongo-repositories.adoc b/src/main/asciidoc/reference/reactive-mongo-repositories.adoc index 386a36406b..a9df36e076 100644 --- a/src/main/asciidoc/reference/reactive-mongo-repositories.adoc +++ b/src/main/asciidoc/reference/reactive-mongo-repositories.adoc @@ -190,10 +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] ---- @@ -210,6 +230,9 @@ Disposable subscription = stream.doOnNext(System.out::println).subscribe(); // … -// Later: Dispose the stream +// 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 bc6fdb7a53..cd59683db0 100644 --- a/src/main/asciidoc/reference/reactive-mongodb.adoc +++ b/src/main/asciidoc/reference/reactive-mongodb.adoc @@ -457,24 +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 has exhausted all results in the cursor. Closing a cursors turns a Stream into a finite stream. However, for capped collections you may use a https://docs.mongodb.com/manual/core/tailable-cursors/[Tailable Cursor] that remains open after the client exhausts the results in the initial cursor. Using Tailable Cursors with a reactive approach allows construction of infinite streams. A Tailable Cursor remains open until it's closed. It emits data as data arrives in a capped collection. Using Tailable Cursors with Collections is not possible as its result would never complete. - -[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 stream -subscription.dispose(); ----- - - [[mongo.reactive.executioncallback]] == Execution callbacks