Skip to content

Commit 9dbd694

Browse files
committed
Update printBlock for changes stream tutorial to use ChangeStreamDocument
1 parent bef1710 commit 9dbd694

File tree

2 files changed

+54
-43
lines changed

2 files changed

+54
-43
lines changed

docs/reference/content/driver-async/tutorials/change-streams.md

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,39 @@ to resume if it encounters a potentially recoverable error.
2323

2424
- Include the following import statements:
2525

26-
```java
27-
import com.mongodb.Block;
28-
import com.mongodb.async.client.*;
29-
import com.mongodb.async.SingleResultCallback;
30-
31-
import com.mongodb.client.model.*;
32-
33-
import org.bson.Document;
34-
35-
import java.util.Arrays;
36-
```
37-
38-
- Include the following code which the examples in the tutorials will use to print the results of the aggregation:
39-
40-
```java
41-
Block<Document> printBlock = new Block<Document>() {
42-
@Override
43-
public void apply(final Document document) {
44-
System.out.println(document.toJson());
45-
}
46-
};
47-
```
26+
```java
27+
import com.mongodb.Block;
28+
import com.mongodb.async.client.*;
29+
import com.mongodb.async.SingleResultCallback;
30+
31+
import com.mongodb.client.model.*;
32+
33+
import org.bson.Document;
34+
35+
import java.util.Arrays;
36+
```
37+
38+
- Include the following callback code which the examples in the tutorials will use:
39+
40+
```java
41+
SingleResultCallback<Void> callbackWhenFinished = new SingleResultCallback<Void>() {
42+
@Override
43+
public void onResult(final Void result, final Throwable t) {
44+
System.out.println("Operation Finished!");
45+
}
46+
};
47+
```
48+
49+
- Include the following code which the examples in the tutorials will use to print the results of the change stream:
50+
51+
```java
52+
Block<ChangeStreamDocument<Document>> printBlock = new Block<>() {
53+
@Override
54+
public void apply(final ChangeStreamDocument<Document> changeStreamDocument) {
55+
System.out.println(changeStreamDocument);
56+
}
57+
};
58+
```
4859

4960
## Connect to a MongoDB Deployment
5061

docs/reference/content/driver/tutorials/change-streams.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ to resume if it encounters a potentially recoverable error.
2323

2424
- Include the following import statements:
2525

26-
```java
27-
import com.mongodb.Block;
28-
import com.mongodb.MongoClient;
29-
import com.mongodb.MongoClientURI;
30-
import com.mongodb.client.MongoCollection;
31-
import com.mongodb.client.MongoDatabase;
32-
import com.mongodb.client.model.changestream.FullDocument;
33-
34-
import org.bson.Document;
35-
```
36-
37-
- Include the following code which the examples in the tutorials will use to print the results of the aggregation:
38-
39-
```java
40-
Block<Document> printBlock = new Block<Document>() {
41-
@Override
42-
public void apply(final Document document) {
43-
System.out.println(document.toJson());
44-
}
45-
};
46-
```
26+
```java
27+
import com.mongodb.Block;
28+
import com.mongodb.MongoClient;
29+
import com.mongodb.MongoClientURI;
30+
import com.mongodb.client.MongoCollection;
31+
import com.mongodb.client.MongoDatabase;
32+
import com.mongodb.client.model.changestream.FullDocument;
33+
import com.mongodb.client.model.changestream.ChangeStreamDocument;
34+
import org.bson.Document;
35+
```
36+
37+
- Include the following code which the examples in the tutorials will use to print the results of the change stream:
38+
39+
```java
40+
Block<ChangeStreamDocument<Document>> printBlock = new Block<>() {
41+
@Override
42+
public void apply(final ChangeStreamDocument<Document> changeStreamDocument) {
43+
System.out.println(changeStreamDocument);
44+
}
45+
};
46+
```
4747

4848
## Connect to a MongoDB Deployment
4949

0 commit comments

Comments
 (0)