Skip to content

Commit 75e5d06

Browse files
getReplicaFromPreferredServerGroup snippet
1 parent cc9dd22 commit 75e5d06

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

modules/concept-docs/pages/data-durability-acid-transactions.adoc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,18 @@ Implicit in the rules for durability, and the process of setting up Server Group
206206
xref:concept-docs:transactions.adoc[multi-document ACID transactions].
207207
====
208208

209-
210-
209+
.getReplicaFromPreferredServerGroup example, using Transactions
210+
[source,java]
211+
----
212+
cluster.transactions().run((ctx) -> {
213+
TransactionGetResult getResult;
214+
try {
215+
getResult = ctx.getReplicaFromPreferredServerGroup(collection, id);
216+
} catch (DocumentUnretrievableException err) {
217+
getResult = ctx.get(collection, id);
218+
}
219+
});
220+
----
211221

212222

213223
== Concurrent Document Mutations

0 commit comments

Comments
 (0)