The JTS version of the Banking application means that the Object Request Broker
will be used. The JBossTS distribution is provided to work with the bundled JacORB version
Note: Ensure that the jacorb jar files are added in your CLASSPATH
java com.arjuna.ats.arjuna.recovery.RecoveryManager
-
Testing the distributed transaction with Implicit Propagation Context
java com.arjuna.demo.jts.remotebank.BankServer
- In a separate window, start the client
java com.arjuna.demo.jts.remotebank.BankClient
-
Testing the distributed transaction with Explicit Propagation Context
java com.arjuna.demo.jts.explicitremotebank.BankServer
- In a separate window, start the client
java com.arjuna.demo.jts.explicitremotebank.BankClient
In both cases (implicit and explicit), the Bank Server, which can be stopped by hand, displays the following lines:
The bank server is now ready...
In both cases (implicit and Explicit), the Bank Client window displays the following lines:
-------------------------------------------------
Bank client
-------------------------------------------------
Select an option :
0. Quit
1. Create a new account.
2. Get an account information.
3. Make a transfer.
4. Credit an account.
5. Withdraw from an account
Your choice :
After entering your choice, the appropriate operation is performed by the
remote Bank object, to get the requested account, and by the account to execute
the credit or withdraw or to return the current balance. Let's consider the following execution.
Enter the number 1 as your choice, then give the name "Foo" as the
account name and "1000" as an initial value of the account to create.
You should get in the server window a result that terminates with the following line
[ Resource for Foo : Commit one phase ]
- Since only one AccountResource then only one CosTransaction.Resource is
involved in the account creation transaction, the two phases needed to get
a consensus in the 2PC protocol are not mandatory. The one phase commit optimisation,
indicated by the "Commit one phase", is applied.
In the same way create a second account with the name "Bar" and the initial balance set to 500.
As a choice now, enter in the client window "3" to make a transfer
(300) from "Foo" to "Bar".
Your choice : 3
- Make a transfer -
-------------------
Take money from : Foo
Put money to : Bar
Transfer amount : 300
In the Server window you should see a result with the following lines
[ Resource for Foo : Prepare ]
[ Resource for Bar : Prepare ]
[ Resource for Foo : Commit ]
[ Resource for Bar : Commit ]
- Now two AccountResource objects, then two CosTransactions.Resource objects are enlisted with the transaction. The
displayed lines show that the two phases, prepare and commit, are applied.
Any attempt to manipulate an account that it doesn't exist leads to throw the NotExistingAccount exception and to rollback
the transaction in progress. For instance, let's withdraw money from an account FooBar not previously created.
Your choice : 5
- Withdraw from an Account -
----------------------------
Amount to withdraw : 200
Beginning a User transaction to withdraw from an account
The requested account does not exist!
ERROR - org.omg.CORBA.TRANSACTION_ROLLEDBACK:
minor code: 50001 completed: No
Using a stand-alone Transaction Server
By default JBossTS does not use a separate transaction manager server: transaction
managers are co-located with each application process to improve performance
and improve application fault-tolerance. When running applications which require
a separate transaction manager, you must set the com.arjuna.ats.jts.transactionManager
property variable, in the jbossts-properties.xml file, to YES.
In a separate window, the stand-alone Transaction Server is launched as follow:
java com.arjuna.ats.jts.TransactionServer [-test]
The option -test allows to see the message "Ready" when the Transaction Server is started.
The Banking application presented above gives the same output.