Sample-jta-plain » History » Version 3
  Henning Blohm, 15.09.2012 10:44 
  
| 1 | 3 | Henning Blohm | h1. Using Z2 with a Transaction Manager | 
|---|---|---|---|
| 2 | 1 | Henning Blohm | |
| 3 | 2 | Henning Blohm | (Work in progress) | 
| 4 | 1 | Henning Blohm | |
| 5 | 2 | Henning Blohm | This sample demonstrates how to use Z2 with the Atomikos transaction manager. There is another sample that shows how to use Z2 with a Spring configured transaction manager. See [[sample-jta-spring]]. In contrast to that, this sample is less sophisticated but probably better suited to understand the underlying mechanics. | 
| 6 | 1 | Henning Blohm | |
| 7 | The Wiki page [[How_to_TransactionManager]] explains the general principles behind transaction handling in Z2. | ||
| 8 | 2 | Henning Blohm | |
| 9 | This sample is stored in "z2-samples.jta-plain":http://redmine.z2-environment.net/projects/z2-samples/repository/z2-samples-jta-plain. | ||
| 10 | |||
| 11 | h2. Pre-Requisites | ||
| 12 | |||
| 13 | This sample assumes the presence of a MySQL database system on localhost with a database called "z_tx_tests" for which a user "tx" with password "tx" has full permissions. If you have a running MySQL server these SQL commands do the trick: | ||
| 14 | |||
| 15 | <pre><code class="SQL"> | ||
| 16 | create database z_tx_tests; | ||
| 17 | grant all on z_tx_tests.* to tx@localhost identified by 'tx'; | ||
| 18 | </code></pre> | ||
| 19 | |||
| 20 | h2. Running the sample | ||
| 21 | |||
| 22 | This sample is run as explained in [[How to run a sample]]. The 5 minutes version: | ||
| 23 | |||
| 24 | <pre><code class="ruby"> | ||
| 25 | mkdir install | ||
| 26 | cd install | ||
| 27 | git clone -b master http://git.z2-environment.net/z2-base.core | ||
| 28 | git clone -b master http://git.z2-environment.net/z2-samples.jta-plain | ||
| 29 | |||
| 30 | # on Linux / Mac OS: | ||
| 31 | cd z2-base.core/run/bin | ||
| 32 | ./gui.sh | ||
| 33 | |||
| 34 | # on Windows: | ||
| 35 | cd z2-base.core\run\bin | ||
| 36 | gui.bat | ||
| 37 | 1 | Henning Blohm | </code></pre> | 
| 38 | 3 | Henning Blohm | |
| 39 | h2. Verifying | ||
| 40 | |||
| 41 | When everything is up, go to http://localhost:8080/tx.plain. You see something like this: | ||
| 42 | |||
| 43 | !plain_thingies.png! | ||
| 44 | |||
| 45 | And indeed, the implemented function is rather obvious: Manage a table of strings. | ||
| 46 | |||
| 47 | h2. Now to the point... | 
