www.arjuna.com news company products standards research library forums contact
Trail map 1. Installation Content 2. The Sample Application 3. Deploying and Testing the Sample Application 4. Making the Sample Application Persistent 5. Recovery From Failure 6. Where Next? Navigation Home Previous Additional Trails Distributed Transaction Processing The X/Open DTP Model The OMG OTS Model Transactions in J2EE Configuring ATS Configuring the Recovery Manager ORB Portability Transactional Object For Java
| print this page
| email this page
> Running The Banking application with JTS The JTS version of the Banking application means that the Object Request Broker will be used. The ArjunaTS distribution is provided to works with JacOrb version 2.1 that can be obtained from the arjuna product page. 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 ArjunaTS 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