@@ -137,6 +137,53 @@ An update operation on the collection produces the following output:
137
137
...
138
138
}
139
139
140
+ Split Large Change Stream Events
141
+ --------------------------------
142
+
143
+ Starting in MongoDB 7.0, you can use the ``$changeStreamSplitLargeEvent``
144
+ aggregation stage to split events that exceed 16 MB into smaller fragments.
145
+ The $changeStreamSplitLargeEvent stage returns the fragments sequentially. You can
146
+ access the fragments by using a change stream cursor. Each fragment
147
+ includes a ``SplitEvent`` object containing the following fields:
148
+
149
+ .. list-table::
150
+ :header-rows: 1
151
+ :widths: 35 65
152
+
153
+ * - Field
154
+ - Description
155
+
156
+ * - ``fragment``
157
+ - The index of the fragment, starting at ``1``
158
+
159
+ * - ``of``
160
+ - The total number of fragments that compose the split event
161
+
162
+ The following example modifies your change stream by using the
163
+ ``$changeStreamSplitLargeEvent`` aggregation stage to split large events:
164
+
165
+ .. code-block:: java
166
+
167
+ ChangeStreamIterable<Document> changeStream = collection.watch(
168
+ Arrays.asList(Document.parse("{ $changeStreamSplitLargeEvent: {} }")));
169
+
170
+ .. note::
171
+
172
+ You can have only one ``$changeStreamSplitLargeEvent`` stage in your
173
+ aggregation pipeline, and it must be the last stage in the pipeline.
174
+
175
+ You can call the ``getSplitEvent()`` method on your change stream cursor to access
176
+ the ``SplitEvent`` as shown in the following example:
177
+
178
+ .. code-block:: java
179
+
180
+ MongoChangeStreamCursor<ChangeStreamDocument<Document>> cursor = changeStream.cursor();
181
+ SplitEvent event = cursor.tryNext().getSplitEvent();
182
+
183
+ For more information on the ``$changeStreamSplitLargeEvent`` aggregation stage,
184
+ see the :manual:`$changeStreamSplitLargeEvent
185
+ </reference/operator/aggregation/changeStreamSplitLargeEvent/>` server documentation.
186
+
140
187
.. _java-change-stream-configure-pre-post:
141
188
142
189
Include Pre-images and Post-images
@@ -287,4 +334,4 @@ output:
287
334
}
288
335
289
336
For a list of options, see the `FullDocument <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/changestream/FullDocument.html>`__
290
- API documentation.
337
+ API documentation.
0 commit comments