Search in sources :

Example 1 with ClientTransactionConfiguration

use of org.apache.ignite.configuration.ClientTransactionConfiguration in project ignite by apache.

the class JavaThinClient method transactionConfiguration.

@Test
void transactionConfiguration() {
    // tag::transaction-config[]
    ClientConfiguration cfg = new ClientConfiguration();
    cfg.setAddresses("localhost:10800");
    cfg.setTransactionConfiguration(new ClientTransactionConfiguration().setDefaultTxTimeout(10000).setDefaultTxConcurrency(TransactionConcurrency.OPTIMISTIC).setDefaultTxIsolation(TransactionIsolation.REPEATABLE_READ));
    IgniteClient client = Ignition.startClient(cfg);
    // end::transaction-config[]
    ClientCache cache = client.createCache(new ClientCacheConfiguration().setName("test").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
    // tag::tx-custom-properties[]
    ClientTransactions tx = client.transactions();
    try (ClientTransaction t = tx.txStart(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ)) {
        cache.put(1, "new value");
        t.commit();
    }
// end::tx-custom-properties[]
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) ClientTransaction(org.apache.ignite.client.ClientTransaction) ClientTransactionConfiguration(org.apache.ignite.configuration.ClientTransactionConfiguration) ClientCache(org.apache.ignite.client.ClientCache) ClientTransactions(org.apache.ignite.client.ClientTransactions) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) ThinClientConfiguration(org.apache.ignite.configuration.ThinClientConfiguration) ClientCacheConfiguration(org.apache.ignite.client.ClientCacheConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

ClientCache (org.apache.ignite.client.ClientCache)1 ClientCacheConfiguration (org.apache.ignite.client.ClientCacheConfiguration)1 ClientTransaction (org.apache.ignite.client.ClientTransaction)1 ClientTransactions (org.apache.ignite.client.ClientTransactions)1 IgniteClient (org.apache.ignite.client.IgniteClient)1 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)1 ClientTransactionConfiguration (org.apache.ignite.configuration.ClientTransactionConfiguration)1 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)1 Test (org.junit.jupiter.api.Test)1