Nested transactions in Apache Ignite

Viewed 46

How to start a transaction without stopping a previously started one?

Any code like this throws exception

try (Transaction tx = Ignition.ignite().transactions().txStart()) {
    ...

    try (Transaction tx = Ignition.ignite().transactions().txStart()) {
        ...
    }

    ...
}

Any Java example or a link would be helpful.

1 Answers

You can start a new transaction in a separate thread.

For example:

Transaction tx1 = Ignition.ignite().transactions().txStart();

new Thread(() -> {
    Transaction tx2 = Ignition.ignite().transactions().txStart();
    ...
    tx2.commit();
}).start();

...

tx1.commit();
Related