Class TailableCursorRequest<T>
java.lang.Object
org.springframework.data.mongodb.core.messaging.TailableCursorRequest<T>
- All Implemented Interfaces:
SubscriptionRequest<org.bson.Document,
T, SubscriptionRequest.RequestOptions>
public class TailableCursorRequest<T>
extends Object
implements SubscriptionRequest<org.bson.Document,T,SubscriptionRequest.RequestOptions>
SubscriptionRequest
implementation to be used to listen to query results in a
Capped Collection using a
Tailable Cursor.
The most trivial use case is subscribing to all events of a specific
collection
.
TailableCursorRequest<Document> request = new TailableCursorRequest<>(System.out::println, () -> "collection-name");
TailableCursorRequest.TailableCursorRequestBuilder
offers a fluent API for creating TailableCursorRequest
with
TailableCursorRequest.TailableCursorRequestOptions
in one go.
TailableCursorRequest<Document> request = TailableCursorRequest.builder()
.collection("collection-name")
.publishTo(System.out::println)
.build();
- Since:
- 2.1
- Author:
- Christoph Strobl, Mark Paluch
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder for creatingTailableCursorRequest
.static class
SubscriptionRequest.RequestOptions
implementation specific to aTailableCursorRequest
.Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.messaging.SubscriptionRequest
SubscriptionRequest.RequestOptions
-
Constructor Summary
ConstructorDescriptionTailableCursorRequest
(MessageListener<org.bson.Document, ? super T> messageListener, SubscriptionRequest.RequestOptions options) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Obtain a shiny newTailableCursorRequest.TailableCursorRequestBuilder
and start defining options in this fancy fluent way.static <T> TailableCursorRequest.TailableCursorRequestBuilder<T>
builder
(MessageListener<org.bson.Document, ? super T> listener) Obtain a shiny newTailableCursorRequest.TailableCursorRequestBuilder
and start defining options in this fancy fluent way.MessageListener<org.bson.Document,
? super T> Obtain theMessageListener
to publishmessages
to.Get theSubscriptionRequest.RequestOptions
specifying the requests behaviour.
-
Constructor Details
-
TailableCursorRequest
public TailableCursorRequest(MessageListener<org.bson.Document, ? super T> messageListener, SubscriptionRequest.RequestOptions options) - Parameters:
messageListener
- must not be null.options
- must not be null.
-
-
Method Details
-
getMessageListener
Description copied from interface:SubscriptionRequest
Obtain theMessageListener
to publishmessages
to.- Specified by:
getMessageListener
in interfaceSubscriptionRequest<org.bson.Document,
T, SubscriptionRequest.RequestOptions> - Returns:
- never null.
-
getRequestOptions
Description copied from interface:SubscriptionRequest
Get theSubscriptionRequest.RequestOptions
specifying the requests behaviour.- Specified by:
getRequestOptions
in interfaceSubscriptionRequest<org.bson.Document,
T, SubscriptionRequest.RequestOptions> - Returns:
- never null.
-
builder
Obtain a shiny newTailableCursorRequest.TailableCursorRequestBuilder
and start defining options in this fancy fluent way. Just don't forget to callbuild()
when done.- Returns:
- new instance of
TailableCursorRequest.TailableCursorRequestBuilder
.
-
builder
public static <T> TailableCursorRequest.TailableCursorRequestBuilder<T> builder(MessageListener<org.bson.Document, ? super T> listener) Obtain a shiny newTailableCursorRequest.TailableCursorRequestBuilder
and start defining options in this fancy fluent way. Just don't forget to callbuild()
when done.- Returns:
- new instance of
TailableCursorRequest.TailableCursorRequestBuilder
.
-