org.apache.ignite.configuration

## Class TransactionConfiguration

- java.lang.Object
- - org.apache.ignite.configuration.TransactionConfiguration

All Implemented Interfaces:
  Serializable

    public class TransactionConfiguration
    extends Object
    implements Serializable

Transactions configuration.

See Also:
  Serialized Form

### Field Summary

Fields
`static long` `DFLT_DEADLOCK_TIMEOUT` Default timeout before starting deadlock detection.
`static int` `DFLT_PESSIMISTIC_TX_LOG_LINGER` Deprecated. Pessimistic tx log linger property has no effect.
`static long` `DFLT_TRANSACTION_TIMEOUT` Default transaction timeout.
`static TransactionConcurrency` `DFLT_TX_CONCURRENCY` Default concurrency mode.
`static TransactionIsolation` `DFLT_TX_ISOLATION` Default transaction isolation level.
`static boolean` `DFLT_TX_SERIALIZABLE_ENABLED` Default value for 'txSerializableEnabled' flag.
`static long` `TX_TIMEOUT_ON_PARTITION_MAP_EXCHANGE` Transaction timeout on partition map synchronization.

### Constructor Summary

Constructors
Constructor and Description
`TransactionConfiguration()` Empty constructor.
`TransactionConfiguration(TransactionConfiguration cfg)`

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`long` `getDeadlockTimeout()` This is an experimental feature.
`TransactionConcurrency` `getDefaultTxConcurrency()` Default cache transaction concurrency to use when one is not explicitly specified.
`TransactionIsolation` `getDefaultTxIsolation()` Default cache transaction isolation to use when one is not explicitly specified.
`long` `getDefaultTxTimeout()` Gets default transaction timeout.
`int` `getPessimisticTxLogLinger()` Deprecated. Pessimistic tx log linger property has no effect.
`int` `getPessimisticTxLogSize()` Deprecated. Pessimistic tx log size property has no effect.
`<T> javax.cache.configuration.Factory<T>` `getTxManagerFactory()` Gets transaction manager factory for integration with JEE app servers.
`String` `getTxManagerLookupClassName()` Deprecated. Use `getTxManagerFactory()` instead.
`long` `getTxTimeoutOnPartitionMapExchange()` Some Ignite operations provoke partition map exchange process within Ignite to ensure the partitions distribution state is synchronized cluster-wide.
`boolean` `isTxSerializableEnabled()` Deprecated.
`boolean` `isUseJtaSynchronization()`
`TransactionConfiguration` `setDeadlockTimeout(long deadlockTimeout)` This is an experimental feature.
`TransactionConfiguration` `setDefaultTxConcurrency(TransactionConcurrency dfltConcurrency)` Sets default transaction concurrency.
`TransactionConfiguration` `setDefaultTxIsolation(TransactionIsolation dfltIsolation)` Sets default transaction isolation.
`TransactionConfiguration` `setDefaultTxTimeout(long dfltTxTimeout)` Sets default transaction timeout in milliseconds.
`TransactionConfiguration` `setPessimisticTxLogLinger(int pessimisticTxLogLinger)` Deprecated. Pessimistic tx log linger property has no effect.
`TransactionConfiguration` `setPessimisticTxLogSize(int pessimisticTxLogSize)` Deprecated. Pessimistic tx log size property has no effect.
`<T> TransactionConfiguration` `setTxManagerFactory(javax.cache.configuration.Factory<T> factory)` Sets transaction manager factory for available `javax.transaction.TransactionManager` implementation, if any.
`TransactionConfiguration` `setTxManagerLookupClassName(String tmLookupClsName)` Deprecated. Use `setTxManagerFactory(Factory)` instead.
`TransactionConfiguration` `setTxSerializableEnabled(boolean txSerEnabled)` Deprecated. This method has no effect, `TransactionIsolation.SERIALIZABLE` isolation is always enabled.
`TransactionConfiguration` `setTxTimeoutOnPartitionMapExchange(long txTimeoutOnPartitionMapExchange)` Sets the transaction timeout that will be enforced if the partition map exchange process starts.
`TransactionConfiguration` `setUseJtaSynchronization(boolean useJtaSync)` Sets the flag that defines whether to use lightweight JTA synchronization callback to enlist into JTA transaction instead of creating a separate XA resource.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### DFLT_TX_SERIALIZABLE_ENABLED

    public static final boolean DFLT_TX_SERIALIZABLE_ENABLED

Default value for 'txSerializableEnabled' flag.

See Also:
  Constant Field Values

#### DFLT_TX_CONCURRENCY

    public static final TransactionConcurrency DFLT_TX_CONCURRENCY

Default concurrency mode.

#### DFLT_TX_ISOLATION

    public static final TransactionIsolation DFLT_TX_ISOLATION

Default transaction isolation level.

#### DFLT_TRANSACTION_TIMEOUT

    public static final long DFLT_TRANSACTION_TIMEOUT

Default transaction timeout.

See Also:
  Constant Field Values

#### TX_TIMEOUT_ON_PARTITION_MAP_EXCHANGE

    public static final long TX_TIMEOUT_ON_PARTITION_MAP_EXCHANGE

Transaction timeout on partition map synchronization.

See Also:
  Constant Field Values

#### DFLT_DEADLOCK_TIMEOUT

    public static final long DFLT_DEADLOCK_TIMEOUT

Default timeout before starting deadlock detection.

See Also:
  Constant Field Values

#### DFLT_PESSIMISTIC_TX_LOG_LINGER

    public static final int DFLT_PESSIMISTIC_TX_LOG_LINGER

Deprecated. Pessimistic tx log linger property has no effect.
Default size of pessimistic transactions log.

See Also:
  Constant Field Values

### Constructor Detail

#### TransactionConfiguration

    public TransactionConfiguration()

Empty constructor.

#### TransactionConfiguration

    public TransactionConfiguration(TransactionConfiguration cfg)

Parameters:
  `cfg` - Configuration to copy.

### Method Detail

#### isTxSerializableEnabled

    @Deprecated
    public boolean isTxSerializableEnabled()

Deprecated.
Gets flag to enable/disable `TransactionIsolation.SERIALIZABLE` isolation level for cache transactions. Serializable level does carry certain overhead and if not used, should be disabled. Default value is `false`.

Returns:
  `True` if serializable transactions are enabled, `false` otherwise.

#### setTxSerializableEnabled

    @Deprecated
    public TransactionConfiguration setTxSerializableEnabled(boolean txSerEnabled)

Deprecated. This method has no effect, `TransactionIsolation.SERIALIZABLE` isolation is always enabled.

Parameters:
  `txSerEnabled` - Flag to enable/disable serializable cache transactions.
Returns:
  `this` for chaining.

#### getDefaultTxConcurrency

    public TransactionConcurrency getDefaultTxConcurrency()

Default cache transaction concurrency to use when one is not explicitly specified. Default value is defined by `DFLT_TX_CONCURRENCY`.

Returns:
  Default cache transaction concurrency.
See Also:
  `Transaction`

#### setDefaultTxConcurrency

    public TransactionConfiguration setDefaultTxConcurrency(TransactionConcurrency dfltConcurrency)

Sets default transaction concurrency.

Parameters:
  `dfltConcurrency` - Default cache transaction concurrency.
Returns:
  `this` for chaining.

#### getDefaultTxIsolation

    public TransactionIsolation getDefaultTxIsolation()

Default cache transaction isolation to use when one is not explicitly specified. Default value is defined by `DFLT_TX_ISOLATION`.

Returns:
  Default cache transaction isolation.
See Also:
  `Transaction`

#### setDefaultTxIsolation

    public TransactionConfiguration setDefaultTxIsolation(TransactionIsolation dfltIsolation)

Sets default transaction isolation.

Parameters:
  `dfltIsolation` - Default cache transaction isolation.
Returns:
  `this` for chaining.

#### getDefaultTxTimeout

    public long getDefaultTxTimeout()

Gets default transaction timeout. Default value is defined by `DFLT_TRANSACTION_TIMEOUT` which is `0` and means that transactions will never time out.

Returns:
  Default transaction timeout.

#### setDefaultTxTimeout

    public TransactionConfiguration setDefaultTxTimeout(long dfltTxTimeout)

Sets default transaction timeout in milliseconds. By default this value is defined by `DFLT_TRANSACTION_TIMEOUT`.

Parameters:
  `dfltTxTimeout` - Default transaction timeout.
Returns:
  `this` for chaining.

#### getTxTimeoutOnPartitionMapExchange

    public long getTxTimeoutOnPartitionMapExchange()

Some Ignite operations provoke partition map exchange process within Ignite to ensure the partitions distribution state is synchronized cluster-wide. Topology update events and a start of a new distributed cache are examples of those operations.

When the partition map exchange starts, Ignite acquires a global lock at a particular stage. The lock can't be obtained until pending transactions are running in parallel. If there is a transaction that runs for a while, then it will prevent the partition map exchange process from the start freezing some operations such as a new node join process.

This property allows to rollback such long transactions to let Ignite acquire the lock faster and initiate the partition map exchange process. The timeout is enforced only at the time of the partition map exchange process.

If not set, default value is `TX_TIMEOUT_ON_PARTITION_MAP_EXCHANGE` which means transactions will never be rolled back on partition map exchange.

Returns:
  Transaction timeout for partition map synchronization in milliseconds.

#### setTxTimeoutOnPartitionMapExchange

    public TransactionConfiguration setTxTimeoutOnPartitionMapExchange(long txTimeoutOnPartitionMapExchange)

Sets the transaction timeout that will be enforced if the partition map exchange process starts.

Parameters:
  `txTimeoutOnPartitionMapExchange` - Transaction timeout value in milliseconds.
Returns:
  `this` for chaining.

#### getDeadlockTimeout

    public long getDeadlockTimeout()

This is an experimental feature. Transactional SQL is currently in a beta status.

Transaction deadlocks occurred for caches configured with `CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT` can be resolved automatically.

Deadlock detection starts when one transaction is waiting for an entry lock more than a timeout specified by this property.

Timeout is specified in milliseconds and `0` means that automatic deadlock detection is disabled. Default value is defined by `DFLT_DEADLOCK_TIMEOUT`.

Returns:
  Timeout before starting deadlock detection.

#### setDeadlockTimeout

    public TransactionConfiguration setDeadlockTimeout(long deadlockTimeout)

This is an experimental feature. Transactional SQL is currently in a beta status.

Sets a timeout before starting deadlock detection for caches configured with `CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT`.

Timeout is specified in milliseconds and `0` means that automatic deadlock detection is disabled. Default value is defined by `DFLT_DEADLOCK_TIMEOUT`.

Parameters:
  `deadlockTimeout` - Timeout value in milliseconds.
Returns:
  `this` for chaining.

#### getPessimisticTxLogSize

    @Deprecated
    public int getPessimisticTxLogSize()

Deprecated. Pessimistic tx log size property has no effect.
Gets size of pessimistic transactions log stored on node in order to recover transaction commit if originating node has left grid before it has sent all messages to transaction nodes.

If not set, default value is `0` which means unlimited log size.

Returns:
  Pessimistic transaction log size.

#### setPessimisticTxLogSize

    @Deprecated
    public TransactionConfiguration setPessimisticTxLogSize(int pessimisticTxLogSize)

Deprecated. Pessimistic tx log size property has no effect.
Sets pessimistic transactions log size.

Parameters:
  `pessimisticTxLogSize` - Pessimistic transactions log size.
Returns:
  `this` for chaining.
See Also:
  `getPessimisticTxLogSize()`

#### getPessimisticTxLogLinger

    @Deprecated
    public int getPessimisticTxLogLinger()

Deprecated. Pessimistic tx log linger property has no effect.
Gets delay, in milliseconds, after which pessimistic recovery entries will be cleaned up for failed node.

If not set, default value is `DFLT_PESSIMISTIC_TX_LOG_LINGER`.

Returns:
  Pessimistic log cleanup delay in milliseconds.

#### setPessimisticTxLogLinger

    @Deprecated
    public TransactionConfiguration setPessimisticTxLogLinger(int pessimisticTxLogLinger)

Deprecated. Pessimistic tx log linger property has no effect.
Sets cleanup delay for pessimistic transaction recovery log for failed node, in milliseconds.

Parameters:
  `pessimisticTxLogLinger` - Pessimistic log cleanup delay.
Returns:
  `this` for chaining.
See Also:
  `getPessimisticTxLogLinger()`

#### getTxManagerLookupClassName

    @Deprecated
    public String getTxManagerLookupClassName()

Deprecated. Use `getTxManagerFactory()` instead.
Gets class name of transaction manager finder for integration for JEE app servers.

Returns:
  Transaction manager finder.

#### setTxManagerLookupClassName

    @Deprecated
    public TransactionConfiguration setTxManagerLookupClassName(String tmLookupClsName)

Deprecated. Use `setTxManagerFactory(Factory)` instead.
Sets look up mechanism for available `TransactionManager` implementation, if any.

Parameters:
  `tmLookupClsName` - Name of class implementing GridCacheTmLookup interface that is used to receive JTA transaction manager.
Returns:
  `this` for chaining.

#### getTxManagerFactory

    public <T> javax.cache.configuration.Factory<T> getTxManagerFactory()

Gets transaction manager factory for integration with JEE app servers.

Type Parameters:
  `T` - Instance of `javax.transaction.TransactionManager`.
Returns:
  Transaction manager factory.
See Also:
  `isUseJtaSynchronization()`

#### setTxManagerFactory

    public <T> TransactionConfiguration setTxManagerFactory(javax.cache.configuration.Factory<T> factory)

Sets transaction manager factory for available `javax.transaction.TransactionManager` implementation, if any.

It allows to use different transactional systems. Implement factory that produce native `javax.transaction.TransactionManager` within your environment.

The following implementations are provided out of the box (jta module must be enabled):

- `org.apache.ignite.cache.jta.jndi.CacheJndiTmFactory` utilizes configured JNDI names to look up a transaction manager.
- `org.apache.ignite.cache.jta.websphere.WebSphereTmFactory` an implementation of Transaction Manager factory to be used within WebSphere Application Server.
- `org.apache.ignite.cache.jta.websphere.WebSphereLibertyTmFactory` an implementation of Transaction Manager factory to be used within WebSphere Liberty.

Ignite will throw IgniteCheckedException if `Factory.create()` method throws any exception, returns `null`-value or returns non-`TransactionManager` instance.

Type Parameters:
  `T` - Instance of `javax.transaction.TransactionManager`.
Parameters:
  `factory` - Transaction manager factory.
Returns:
  `this` for chaining.
See Also:
  `setUseJtaSynchronization(boolean)`

#### isUseJtaSynchronization

    public boolean isUseJtaSynchronization()

Returns:
  Whether to use JTA `javax.transaction.Synchronization` instead of `javax.transaction.xa.XAResource`.
See Also:
  `getTxManagerFactory()`

#### setUseJtaSynchronization

    public TransactionConfiguration setUseJtaSynchronization(boolean useJtaSync)

Sets the flag that defines whether to use lightweight JTA synchronization callback to enlist into JTA transaction instead of creating a separate XA resource. In some cases this can give performance improvement, but keep in mind that most of the transaction managers do not allow to add more that one callback to a single transaction.

Parameters:
  `useJtaSync` - Whether to use JTA `javax.transaction.Synchronization` instead of `javax.transaction.xa.XAResource`.
Returns:
  `this` for chaining.
See Also:
  `setTxManagerFactory(Factory)`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021