Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
23.2. Configure Transactions
23.2.1. Configure Transactions (Library Mode) Link kopierenLink in die Zwischenablage kopiert!
Procedure 23.1. Configure Transactions in Library Mode (XML Configuration)
Set the Transaction Mode
See the table below this procedure for a list of available lookup classes.<namedCache ...> <transaction transactionMode="{TRANSACTIONAL,NON_TRANSACTIONAL}"> ... </namedCache><namedCache ...> <transaction transactionMode="{TRANSACTIONAL,NON_TRANSACTIONAL}"> ... </namedCache>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Transaction Manager
ThetransactionModeelement configures whether or not the cache is transactional.<namedCache ...> <transaction transactionMode="TRANSACTIONAL" transactionManagerLookupClass="{TransactionManagerLookupClass}"> </namedCache><namedCache ...> <transaction transactionMode="TRANSACTIONAL" transactionManagerLookupClass="{TransactionManagerLookupClass}"> </namedCache>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Locking Mode
ThelockingModeparameter determines if the optimistic or pessimistic locking method is used. If the cache is non-transactional, the locking mode is ignored. The default value for this parameter isOPTIMISTIC.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify Synchronization
TheuseSynchronizationelement configures the cache to register a synchronization with the transaction manager, or register itself as an XA resource. The default value for this element istrue(use synchronization).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Recovery
Therecoveryelement enables recovery for the cache when set totrue.TherecoveryInfoCacheNameparameter sets the name of the cache where recovery information is held. The default name of the cache is__recoveryInfoCacheName__.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Write Skew Check
ThewriteSkewcheck determines if a modification to the entry from a different transaction should roll back the transaction. Write skew set totruerequiresisolation_levelset toREPEATABLE_READ. The default value forwriteSkewandisolation_levelarefalseandREAD_COMMITTEDrespectively.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Entry Versioning
For clustered caches, enable write skew check by enabling entry versioning and setting its value toSIMPLE.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure 23.2. Configure Transactions in Library Mode (Programmatic Configuration)
Set the Transaction Mode
Set the transaction mode as follows:Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL);Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Transaction Manager
See the table below this procedure for a list of available lookup classes.Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new GenericTransactionManagerLookup());Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new GenericTransactionManagerLookup());Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Locking Mode
ThelockingModevalue determines whether optimistic or pessimistic locking is used. If the cache is non-transactional, the locking mode is ignored. The default value isOPTIMISTIC.Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new GenericTransactionManagerLookup()); .lockingMode(LockingMode.OPTIMISTIC);Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new GenericTransactionManagerLookup()); .lockingMode(LockingMode.OPTIMISTIC);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify Synchronization
TheuseSynchronizationvalue configures the cache to register a synchronization with the transaction manager, or register itself as an XA resource. The default value istrue(use synchronization).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Recovery
Therecoveryparameter enables recovery for the cache when set totrue.TherecoveryInfoCacheNamesets the name of the cache where recovery information is held. The default name of the cache is specified byRecoveryConfiguration.DEFAULT_RECOVERY_INFO_CACHE.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Write Skew Check
ThewriteSkewcheck determines if a modification to the entry from a different transaction should roll back the transaction. Write skew set totruerequiresisolation_levelset toREPEATABLE_READ. The default value forwriteSkewandisolation_levelarefalseandREAD_COMMITTEDrespectively.Configuration config = new ConfigurationBuilder()/* ... */.locking() .isolationLevel(IsolationLevel.REPEATABLE_READ).writeSkewCheck(true);Configuration config = new ConfigurationBuilder()/* ... */.locking() .isolationLevel(IsolationLevel.REPEATABLE_READ).writeSkewCheck(true);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Entry Versioning
For clustered caches, enable write skew check by enabling entry versioning and setting its value toSIMPLE.Configuration config = new ConfigurationBuilder()/* ... */.versioning() .enable() .scheme(VersioningScheme.SIMPLE);Configuration config = new ConfigurationBuilder()/* ... */.versioning() .enable() .scheme(VersioningScheme.SIMPLE);Copy to Clipboard Copied! Toggle word wrap Toggle overflow
| Class Name | Details |
|---|---|
| org.infinispan.transaction.lookup.DummyTransactionManagerLookup | Used primarily for testing environments. This testing transaction manager is not for use in a production environment and is severely limited in terms of functionality, specifically for concurrent transactions and recovery. |
| org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup | The default transaction manager when Red Hat JBoss Data Grid runs in a standalone environment. It is a fully functional JBoss Transactions based transaction manager that overcomes the functionality limits of the DummyTransactionManager. |
| org.infinispan.transaction.lookup.GenericTransactionManagerLookup | GenericTransactionManagerLookup is used by default when no transaction lookup class is specified. This lookup class is recommended when using JBoss Data Grid with Java EE-compatible environment that provides a TransactionManager interface, and is capable of locating the Transaction Manager in most Java EE application servers. If no transaction manager is located, it defaults to DummyTransactionManager. |
| org.infinispan.transaction.lookup.JBossTransactionManagerLookup | The JbossTransactionManagerLookup finds the standard transaction manager running in the application server. This lookup class uses JNDI to look up the TransactionManager instance, and is recommended when custom caches are being used in JTA transactions. |