Skip to content

Commit d2519eb

Browse files
DATAMONGO-1818 - Polishing.
Move overlapping/duplicate documentation into one place. Original Pull Request: spring-projects#512
1 parent d7a8509 commit d2519eb

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

src/main/asciidoc/reference/reactive-mongo-repositories.adoc

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,30 @@ public interface PersonRepository extends ReactiveMongoRepository<Person, String
190190
[[mongo.reactive.repositories.infinite-streams]]
191191
== Infinite Streams with Tailable Cursors
192192

193-
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.
193+
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 https://docs.mongodb.com/manual/core/capped-collections/[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 is closed externally. It emits data as new documents arrive in a capped collection.
194194

195195
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.
196196

197-
Spring Data MongoDB Reactive repositories support infinite streams by annotating a query method with `@Tailable`. This works for methods returning `Flux` or other reactive types capable of emitting multiple elements.
198197

198+
.Infinite Stream queries with ReactiveMongoOperations
199+
====
200+
[source,java]
201+
----
202+
Flux<Person> stream = template.tail(query(where("name").is("Joe")), Person.class);
203+
204+
Disposable subscription = stream.doOnNext(person -> System.out.println(person)).subscribe();
205+
206+
// …
207+
208+
// Later: Dispose the subscription to close the stream
209+
subscription.dispose();
210+
----
211+
====
212+
213+
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.
214+
215+
.Infinite Stream queries with ReactiveMongoRepository
216+
====
199217
[source,java]
200218
----
201219
@@ -215,3 +233,6 @@ Disposable subscription = stream.doOnNext(System.out::println).subscribe();
215233
// Later: Dispose the subscription to close the stream
216234
subscription.dispose();
217235
----
236+
====
237+
238+
TIP: Capped collections can be created via `MongoOperations.createCollection`. Just provide the required `CollectionOptions.empty().capped()...`

src/main/asciidoc/reference/reactive-mongodb.adoc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -457,25 +457,6 @@ NOTE: This example is meant to show the use of save, update and remove operation
457457

458458
The query syntax used in the example is explained in more detail in the section <<mongo.query,Querying Documents>>. Additional documentation can be found in <<mongo-template, the blocking MongoTemplate>> section.
459459

460-
[[mongo.reactive.tailcursors]]
461-
== Infinite Streams
462-
463-
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.
464-
465-
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.
466-
467-
[source,java]
468-
----
469-
Flux<Person> stream = template.tail(query(where("name").is("Joe")), Person.class);
470-
471-
Disposable subscription = stream.doOnNext(person -> System.out.println(person)).subscribe();
472-
473-
// …
474-
475-
// Later: Dispose the subscription to close the stream
476-
subscription.dispose();
477-
----
478-
479460
[[mongo.reactive.executioncallback]]
480461
== Execution callbacks
481462

0 commit comments

Comments
 (0)