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[]
}
Aggregations