Browse Source

Fix code snippet in change streams reference documentation.

Closes: #4376
issue/3380
Christoph Strobl 3 years ago
parent
commit
5ffaa79f4e
No known key found for this signature in database
GPG Key ID: 8CC1AB53391458C8
  1. 10
      src/main/asciidoc/reference/change-streams.adoc

10
src/main/asciidoc/reference/change-streams.adoc

@ -25,16 +25,16 @@ The following example shows how to use Change Streams with `MessageListener` ins
[source,java] [source,java]
---- ----
MessageListenerContainer container = new DefaultMessageListenerContainer(template); MessageListenerContainer container = new DefaultMessageListenerContainer(template);
container.start(); <1> container.start(); <1>
MessageListener<ChangeStreamDocument<Document>, User> listener = System.out::println; <2> MessageListener<ChangeStreamDocument<Document>, User> listener = System.out::println; <2>
ChangeStreamRequestOptions options = new ChangeStreamRequestOptions("user", ChangeStreamOptions.empty()); <3> ChangeStreamRequestOptions options = new ChangeStreamRequestOptions("db", "user", ChangeStreamOptions.empty()); <3>
Subscription subscription = container.register(new ChangeStreamRequest<>(listener, options), User.class); <4> Subscription subscription = container.register(new ChangeStreamRequest<>(listener, options), User.class); <4>
// ... // ...
container.stop(); <5> container.stop(); <5>
---- ----
<1> Starting the container initializes the resources and starts `Task` instances for already registered `SubscriptionRequest` instances. Requests added after startup are ran immediately. <1> Starting the container initializes the resources and starts `Task` instances for already registered `SubscriptionRequest` instances. Requests added after startup are ran immediately.
<2> Define the listener called when a `Message` is received. The `Message#getBody()` is converted to the requested domain type. Use `Document` to receive raw results without conversion. <2> Define the listener called when a `Message` is received. The `Message#getBody()` is converted to the requested domain type. Use `Document` to receive raw results without conversion.

Loading…
Cancel
Save