Distributed Transactions from the Kotlin SDK

  • how-to
    +
    Distributed ACID Transactions with JVM SDKs. Kotlin transactions are available as a developer preview, or use Java ACID transactions within the Kotlin SDK

    With Kotlin SDK 1.4.4, multi-document ACID transactions is available as a developer preview — the Kotlin transactions API is still "volatile", meaning it could change without notice as we refine it.

    Kotlin Transactions — Developer Preview

    If you are interested in trying out the developer preview of Kotlin multi-document ACID transactions, introduced with SDK 1.4.4, the following resources will help you to get started:

    The Kotlin transactions API is still "volatile", meaning it could change without notice as we refine it based on your feedback.

    Java Transactions from the Kotlin SDK

    To implement the Java SDK implementation of distributed ACID transactions into your Kotlin client code, you will need to include the Couchbase Java SDK in your project.

    Create a com.couchbase.client.java.Cluster in your Kotlin app with the normal Java calls (Cluster.connect(…​)), and then do transactions on it as normal, e.g.:

    javaCluster.transactions().run(ctx => { /* your transaction logic here */ })

    So in your app you have both a com.couchbase.client.java.Cluster and a com.couchbase.client.kotlin.Cluster, which are independent connections.

    Additional Information

    For more information on Java transactions, read our guide in the Java documentation: