arjuna logoarjuna strap line


print this page
email this page

The JTS version of the Banking application means that the Object Request Broker will be used. The JBossTS distribution is provided to works with JacOrb version 2.1 that can be obtained from the same download location as JBossTS.

Note: Ensure that the jacorb jar files are added in your CLASSPATH

To launch the JTS version of the Banking application, execute the following java program

java com.arjuna.demo.jts.localbank.BankClient

Once one of the program given above is launched the following lines are displayed:

       
-------------------------------------------------
   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 introducing your choice, the appropriate operation is performed by the 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 the following lines:

Your choice : 1
- Create a new account -
------------------------
Name : Foo
Initial balance : 1000
Beginning a User transaction to create account
[ Connected to 192.168.0.2:4799 from local port 4924 ]
Attempt to commit the account creation transaction /[ 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 "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
Beginning a User transaction to Transfer money
[ 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 -
----------------------------
Give the Account name : FooBar
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 "(ats_install_dir)/etc/arjunajts-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.

Copyright 2002-2005 Arjuna Technologies All Rights Reserved.
info@arjuna.com +44 191 243 0676