|
| 1 | += Configuration |
| 2 | + |
| 3 | +BTM configuration settings are stored in a `Configuration` object. It can be obtained by calling `TransactionManagerServices.getConfiguration()`. All settings are documented in the javadoc and you should refer to it to know what can be configured. |
| 4 | + |
| 5 | +== Contents |
| 6 | + |
| 7 | +* <<howConfig,How to configure BTM>> |
| 8 | +** <<props,The properties configuration file>> |
| 9 | +** <<setting,Setting values directly on the Configuration object>> |
| 10 | +* <<configSettings,Configurable settings>> |
| 11 | +** <<txEngine,Transaction engine settings>> |
| 12 | +** <<journal,Journal settings>> |
| 13 | +** <<timers,Timers settings>> |
| 14 | +** <<resourceLoader,Resource Loader settings>> |
| 15 | +* <<pools,Connection pools settings>> |
| 16 | + |
| 17 | +[[howConfig]] |
| 18 | +== How to configure BTM |
| 19 | + |
| 20 | +The `Configuration` object is implemented with sensible default settings. For a first time user, all default settings are good enough. After the initial testing phase, you might want to change some settings. This can be done in two ways: via a properties configuration file or by setting values directly on the Configuration object. |
| 21 | + |
| 22 | +[[props]] |
| 23 | +=== The properties configuration file |
| 24 | + |
| 25 | +You can create a properties file in which you'll set some configuration settings. All the ones you omit will keep their default value. |
| 26 | +The file can be stored anywhere on the file system in which case you need to set the `bitronix.tm.configuration` system property to tell BTM where the file lies. This is generally done by adding a -D argument to the virtual machine's command line: |
| 27 | + |
| 28 | + java -Dbitronix.tm.configuration=./my-btm-config.properties MyClass |
| 29 | + |
| 30 | +Another way is to call the properties file `bitronix-default-config.properties` and store it at the root of your classpath. |
| 31 | +The properties file is in the default format `key=value`. Ant-like references (`${some.property.name}`) to other properties or to system properties (defined with -D on the command line) are supported. |
| 32 | + |
| 33 | +[[setting]] |
| 34 | +=== Setting values directly on the Configuration object |
| 35 | +You can call any setter you want on the object you get from the call to `TransactionManagerServices.getConfiguration()`. This is convenient if you do not want to use the properties file to configure BTM but want to leverage - for instance - Spring instead. |
| 36 | + |
| 37 | + Configuration conf = TransactionManagerServices.getConfiguration(); |
| 38 | + conf.setServerId("jvm-1"); |
| 39 | + conf.setLogPart1Filename("./tx-logs/part1.btm"); |
| 40 | + conf.setLogPart2Filename("./tx-logs/part2.btm"); |
| 41 | + |
| 42 | +.Read only configuration |
| 43 | +**** |
| 44 | +Once BTM has started, any attempt to call a set method on the Configuration object will throw a `IllegalStateException`. |
| 45 | +**** |
| 46 | + |
| 47 | +Since the Configuration object is a singleton, there is no need to pass it to any other object, BTM will pick it up at startup. |
| 48 | + |
| 49 | +.Configuration dropped after restart |
| 50 | +**** |
| 51 | +The Configuration object is dropped during BTM shutdown. You need to call all setters methods again before you restart the transaction manager. Keep this in mind if you plan to hot-redeploy your application in your application server. |
| 52 | +**** |
| 53 | + |
| 54 | +[[configSettings]] |
| 55 | +== Configurable settings |
| 56 | + |
| 57 | +There are many different settings that are configurable in the transaction manager. Fortunately, all defaults settings are usually good enough to get started. You only need to tune them when required. |
| 58 | + |
| 59 | +[[txEngine]] |
| 60 | +=== Transaction engine settings |
| 61 | + |
| 62 | +These configurable properties are related to the transaction manager's core. |
| 63 | + |
| 64 | +See also https://github.com/bitronix/btm/blob/master/btm/src/main/java/bitronix/tm/Configuration.java. |
| 65 | + |
| 66 | +[options="header", cols="4*"] |
| 67 | +|==== |
| 68 | +|File property name|Configuration property name|Default value|Description |
| 69 | +|bitronix.tm.serverId |
| 70 | +|serverId |
| 71 | +|The machine's IP address but that's unsafe for production usage |
| 72 | +|a stable ASCII string that must uniquely identify this TM instance. It must not exceed 51 characters or it will be truncated. |
| 73 | +|bitronix.tm.2pc.async |
| 74 | +|asynchronous2Pc |
| 75 | +|false |
| 76 | +|Should two phase commit be executed asynchronously? Asynchronous two phase commit will improve 2PC execution time when there are many resources enlisted in transactions but can be very CPU intensive when used on JDK 1.4 without the java.util.concurrent backport implementation available on the classpath. It also makes debugging more complex. link:ImplementationDetails.html#asynchronous2Pc[See here for more details]. |
| 77 | +|bitronix.tm.2pc.warnAboutZeroResourceTransactions |
| 78 | +|warnAboutZeroResourceTransaction |
| 79 | +|true |
| 80 | +|Should transactions executed without a single enlisted resource result in a warning or not? Most of the time transactions executed with no enlisted resource reflect a bug or a mis-configuration somewhere. |
| 81 | +|bitronix.tm.2pc.debugZeroResourceTransactions debugZeroResourceTransaction false Should creation and commit call stacks of transactions executed without a single enlisted resource tracked and logged or not? This is a companion to `warnAboutZeroResourceTransaction` where the transaction creation and commit call stacks could help you identify the culprit code. |
| 82 | +|bitronix.tm.disableJmx |
| 83 | +|disableJmx |
| 84 | +|false |
| 85 | +|The transaction manager registers objects in the JMX registry by default if available. Set this to true to never register JMX objects. |
| 86 | +|bitronix.tm.jndi.userTransactionName |
| 87 | +|jndiUserTransactionName |
| 88 | +|java:comp/UserTransaction |
| 89 | +|The name under which the transaction manager will be bound in the internal JNDI provider. |
| 90 | +|bitronix.tm.allowMultipleLrc allowMultipleLrc false Should the transaction manager allow multiple LRC resources to be enlisted into the same transaction? Having multiple LRC resources participate in a transaction gives up the recovery guarantee but sometimes is useful in development mode. |
| 91 | +|bitronix.tm.currentNodeOnlyRecovery |
| 92 | +|currentNodeOnlyRecovery |
| 93 | +|true |
| 94 | +|Set this to true if you run multiple instances of the transaction manager on the same JMS and JDBC resources to avoid the recovery process to try to recover transactions started by another node. See here for more details. |
| 95 | +|==== |
| 96 | + |
| 97 | +[[journal]] |
| 98 | +=== Journal settings |
| 99 | + |
| 100 | +These configurable properties are related to the disk journal used to record recovery information. |
| 101 | + |
| 102 | +See also https://github.com/bitronix/btm/blob/master/btm/src/main/java/bitronix/tm/Configuration.java. |
| 103 | + |
| 104 | +[options="header", cols="4*"] |
| 105 | +|==== |
| 106 | +|File property name|Configuration property name|Default value|Description |
| 107 | +|bitronix.tm.journal |
| 108 | +|journal |
| 109 | +|disk |
| 110 | +|Set the journal to be used to record transaction logs. This can be any of `disk`, `null` or a class name. The disk journal is a classic implementation using two fixed-size files and disk forces, the null journal just allows one to disable logging. This can be useful to run tests. *Do not use the null journal on production as without transaction logs, atomicity cannot be guaranteed.* |
| 111 | +|bitronix.tm.journal.disk.logPart1Filename |
| 112 | +|logPart1Filename |
| 113 | +|btm1.tlog |
| 114 | +|Journal fragment file 1. |
| 115 | +|bitronix.tm.journal.disk.logPart2Filename |
| 116 | +|logPart2Filename |
| 117 | +|btm2.tlog |
| 118 | +|Journal fragment file 2. |
| 119 | +|bitronix.tm.journal.disk.forcedWriteEnabled |
| 120 | +|forcedWriteEnabled |
| 121 | +|true |
| 122 | +|Are logs forced to disk? *Do not set to false on production since without disk force, atomicity cannot be guaranteed.* |
| 123 | +|bitronix.tm.journal.disk.forceBatchingEnabled |
| 124 | +|forceBatchingEnabled |
| 125 | +|true |
| 126 | +|Are disk forces batched? Disabling batching can seriously lower the transaction manager's throughput. |
| 127 | +|bitronix.tm.journal.disk.maxLogSize |
| 128 | +|maxLogSize |
| 129 | +|2 |
| 130 | +|Maximum size in megabytes of the journal fragments. Larger logs allow transactions to stay longer in-doubt but the TM pauses longer when a fragment is full. |
| 131 | +|bitronix.tm.journal.disk.filterLogStatus |
| 132 | +|filterLogStatus |
| 133 | +|false |
| 134 | +|Should only mandatory logs be written? Enabling this parameter lowers space usage of the fragments but makes debugging more complex. |
| 135 | +|bitronix.tm.journal.disk.skipCorruptedLogs |
| 136 | +|skipCorruptedLogs |
| 137 | +|false |
| 138 | +|Should corrupted transactions log entries be skipped? Use only at last resort when all you have to recover is a pair of corrupted files. |
| 139 | +|==== |
| 140 | + |
| 141 | +[[timers]] |
| 142 | +=== Timers settings |
| 143 | + |
| 144 | +The transaction manager heavily relies on timeouts. All of them can be configured. |
| 145 | + |
| 146 | +See also https://github.com/bitronix/btm/blob/master/btm/src/main/java/bitronix/tm/Configuration.java. |
| 147 | + |
| 148 | +[options="header", cols="4*"] |
| 149 | +|==== |
| 150 | +|File property name|Configuration property name|Default value|Description |
| 151 | +|bitronix.tm.timer.defaultTransactionTimeout |
| 152 | +|defaultTransactionTimeout |
| 153 | +|60 |
| 154 | +|Default transaction timeout in seconds. |
| 155 | +|bitronix.tm.timer.gracefulShutdownInterval |
| 156 | +|gracefulShutdownInterval |
| 157 | +|60 |
| 158 | +|Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time. |
| 159 | +|bitronix.tm.timer.backgroundRecoveryInterval |
| 160 | +|backgroundRecoveryInterval |
| 161 | +|0 |
| 162 | +|*Deprecated* Interval in minutes at which to run the recovery process in the background. Cannot be disabled. |
| 163 | +|bitronix.tm.timer.backgroundRecoveryIntervalSeconds |
| 164 | +|backgroundRecoveryIntervalSeconds |
| 165 | +|60 |
| 166 | +|Interval in seconds at which to run the recovery process in the background. Cannot be disabled. |
| 167 | +|==== |
| 168 | + |
| 169 | +[[resourceLoader]] |
| 170 | +=== Resource Loader settings |
| 171 | + |
| 172 | +The resource loader loads and configures XA resources using configuration stored in a properties file. See the Resource Loader page for more details. |
| 173 | + |
| 174 | +See also https://github.com/bitronix/btm/blob/master/btm/src/main/java/bitronix/tm/Configuration.java. |
| 175 | + |
| 176 | +[options="header", cols="4*"] |
| 177 | +|==== |
| 178 | +|File property name |Configuration property name |Default value |Description |
| 179 | +|bitronix.tm.resource.configuration |
| 180 | +|resourceConfigurationFilename |
| 181 | +|none (optional) |
| 182 | +|Resource Loader configuration file name. |
| 183 | +|==== |
| 184 | + |
| 185 | +[[pools]] |
| 186 | +== Connection pools settings |
| 187 | + |
| 188 | +JDBC and JMS connection pools configuration are discussed in details in the JDBC pools configuration and the JMS pools configuration pages. Alternatively you can use the Resource Loader instead. |
0 commit comments