Getting Started with Distributed Transactions in the ScalarDB Cluster .NET Client SDK
The ScalarDB Cluster .NET Client SDK supports the distributed transaction functionality of ScalarDB Cluster. The SDK includes transaction and manager abstractions for easier communication within a cluster.
Although we recommend using asynchronous methods as in the following examples, you can use synchronous versions instead.
For details about distributed SQL transactions, see Getting Started with Distributed SQL Transactions in the ScalarDB Cluster .NET Client SDK.
Install the SDK​
Install the same major and minor version of the SDK as ScalarDB Cluster into the .NET project. You can do this by using the built-in NuGet package manager, replacing <MAJOR>.<MINOR> with the version that you're using:
dotnet add package ScalarDB.Client --version '<MAJOR>.<MINOR>.*'
Create a settings file​
Create a scalardb-options.json file and add the following, replacing <HOSTNAME_OR_IP_ADDRESS> with the FQDN or the IP address, and <PORT> with the port number (60053 by default) of your cluster:
{
"ScalarDbOptions": {
"Address": "http://<HOSTNAME_OR_IP_ADDRESS>:<PORT>",
"HopLimit": 10
}
}
For details about settings files and other ways to configure the client, see Client configuration.
Get a transaction manager​
You need to get a transaction manager for distributed transactions. To get the transaction manager, you can use TransactionFactory as follows:
// Pass the path to the settings file created in the previous step.
var factory = TransactionFactory.Create("scalardb-options.json");
using var manager = factory.GetTransactionManager();