29.2. Configure Transactions
29.2.1. Configure Transactions (Library Mode)
In Red Hat JBoss Data Grid, transactions in Library mode can be configured with synchronization and transaction recovery. Transactions in their entirety (which includes synchronization and transaction recovery) are not available in Remote Client-Server mode.
In order to execute a cache operation, the cache requires a reference to the environment's Transaction Manager. Configure the cache with the class name that belongs to an implementation of the
TransactionManagerLookup
interface. When initialized, the cache creates an instance of the specified class and invokes its getTransactionManager()
method to locate and return a reference to the Transaction Manager.
In Library mode, transactions are configured as follows:
Procedure 29.1. Configure Transactions in Library Mode (XML Configuration)
<local-cache name="default" <!-- Additional configuration information here -->> <transaction mode="BATCH" stop-timeout="60000" auto-commit="true" protocol="DEFAULT" recovery-cache="recoveryCache"> <locking <!-- Additional configuration information here --> > <versioning versioningScheme="SIMPLE"/> <!-- Additional configuration information here --> </local-cache>
- Enable
transactions
by defining amode
. By default the mode isNONE
, therefore disabling transactions. Valid transaction modes areBATCH
,NON_XA
,NON_DURABLE_XA
,FULL_XA
. - Define a
stop-timeout
, so that if there are any ongoing transactions when a cache is stopped the instance will wait for ongoing transactions to finish. Defaults to30000
milliseconds. - Enable
auto-commit
, so that single operation transactions do not need to be manually initiated. Defaults totrue
. - Define the commit
protocol
in use. Valid commit protocols areDEFAULT
andTOTAL_ORDER
. - Define the name of the
recovery-cache
, where recovery related information is kept. Defaults to__recoveryInfoCacheName__
. - Enable
versioning
of entries by defining theversioningScheme
attribute asSIMPLE
. Defaults toNONE
, indicating that versioning is disabled.
29.2.2. Configure Transactions (Remote Client-Server Mode)
Red Hat JBoss Data Grid does not offer transactions in Remote Client-Server mode. The default and only supported configuration is non-transactional, which is set as follows:
Example 29.1. Transaction Configuration in Remote Client-Server Mode
<cache> <!-- Additional configuration elements here --> <transaction mode="NONE" /> <!-- Additional configuration elements here --> </cache>