<?xml version="1.0"?>
<!--
  JBoss, Home of Professional Open Source
  Copyright 2006, JBoss Inc., and individual contributors as indicated
  by the @authors tag.  All rights reserved. 
  See the copyright.txt in the distribution for a full listing 
  of individual contributors.
  This copyrighted material is made available to anyone wishing to use,
  modify, copy, or redistribute it subject to the terms and conditions
  of the GNU General Public License, v. 2.0.
  This program is distributed in the hope that it will be useful, but WITHOUT A 
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
  PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  You should have received a copy of the GNU General Public License,
  v. 2.0 along with this distribution; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
  MA  02110-1301, USA.
  
  (C) 2005-2006,
  @author JBoss Inc.
-->
<page title="Arjuna Technologies Limited: Trail map: Running and Testing Examples" rootpath="../..">
	<header>         Trail map: Running and Testing Examples     </header>
	<content>
		<navigation>
			<links include="includes/www_arjuna_com_navigation.xml"/>
			<links include="includes/trailmap_navigation.xml"/>
			<links title="Navigation">
				<link ref="index.html">Home</link>
				<link ref="part5_testing_jts.html">Previous</link>
			</links>
			<links include="includes/trailmap_additional.xml"/>
		</navigation>
		<area title="Running The Banking application with JTS">
			<html>
				<p>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 <a class="linkscoloured" href="http://www.arjuna.com/products/arjunats/download/index.html">arjuna 
  product page</a>.</p>
				<p>
				<strong>Note</strong>: Ensure that the jacorb jar files are added in your CLASSPATH</p>
				<ul>
					<li>In a separate window launch the <a class="linkscoloured" href="ArjunaTS_Recovery.html">Recovery Manager</a>, as follow.</li>
				</ul>
				<blockquote>
					<pre>java com.arjuna.ats.arjuna.recovery.RecoveryManager</pre>
				</blockquote>
				
				<ol>
					<li><b>Testing the distributed transaction with <a class="linkscoloured" href="part5_jts_implicit.html"><b>Implicit Propagation Context</b></a></b>
					</li>
				</ol>
				<ul>
					<li>Start the Server</li>
				</ul>
				<blockquote>
					<font face="Courier New, Courier, mono">java com.arjuna.demo.jts.remotebank.BankServer</font>
				</blockquote>
				<ul>
					<li>In a separate window, start the client</li>
				</ul>
				<blockquote>
					<font face="Courier New, Courier, mono">java com.arjuna.demo.jts.remotebank.BankClient</font>
				</blockquote>
				<ol start="2">
					<li><b>Testing the distributed transaction with <a class="linkscoloured" href="part5_jts_explicit.html"><b>Explicit Propagation Context</b></a></b>
					</li>
				</ol>
				<ul>
					<li>Start the Server</li>
				</ul>
				<blockquote>
					<font face="Courier New, Courier, mono">java com.arjuna.demo.jts.explicitremotebank.BankServer</font>
				</blockquote>
				<ul>
					<li>In a separate window, start the client</li>
				</ul>
				<blockquote>
					<font face="Courier New, Courier, mono">java com.arjuna.demo.jts.explicitremotebank.BankClient</font>
				</blockquote>
				<p>In both cases (implicit and explicit), the Bank Server, which can be stopped by hand, displays the following lines:</p>
				<blockquote>
					<font face="Courier New, Courier, mono">The bank server is now ready...</font>
				</blockquote>
				<p>In both cases (implicit and Explicit), the Bank Client window displays the  following lines:</p>
				<blockquote>
					<font face="Courier New, Courier, mono">-------------------------------------------------<br/>
					   Bank client<br/>
					-------------------------------------------------<br/>
					<br/>
					Select an option :<br/>
					   0. Quit<br/>
					   1. Create a new account.<br/>
					   2. Get an account information.<br/>
					   3. Make a transfer.<br/>
					   4. Credit an account.<br/>
					   5. Withdraw from an account<br/>
					<br/>
					Your choice :</font>
				</blockquote>
				<p>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. </p>
				<p>Enter the number 1 as your choice, then give the name &quot;Foo&quot; as the 
  account name and &quot;1000&quot; as an initial value of the account to create. 
  You should get in the server window a result that terminates with the following line</p>
				<blockquote>
					<font face="Courier New, Courier, mono">[ Resource for Foo : Commit one phase ]</font>
				</blockquote>
				<ul>
					<li>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 &quot;Commit one phase&quot;, is applied. </li>
				</ul>
				<p>In the same way create a second account with the name &quot;Bar&quot; and the initial balance set to 500. </p>
				<p>As a choice now, enter in the client window &quot;3&quot; to make a transfer 
  (300) from &quot;Foo&quot; to &quot;Bar&quot;. </p>
				<blockquote>
					<font face="Courier New, Courier, mono">Your choice : 3<br/>
					- Make a transfer -<br/>
					-------------------<br/>
					<br/>
					Take money from : Foo<br/>
					Put money to : Bar<br/>
					Transfer amount : 300</font>
				</blockquote>
				<p> In the Server window you should see a result with the following lines</p>
				<blockquote>
					<font face="Courier New, Courier, mono">[ Resource for Foo : Prepare ]<br/>
					[ Resource for Bar : Prepare ]<br/>
					[ Resource for Foo : Commit ]<br/>
					[ Resource for Bar : Commit ]</font>
				</blockquote>
				<ul>
					<li>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. </li>
				</ul>
				<p>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.</p>
				<blockquote>
					<font face="Courier New, Courier, mono">Your choice : 5<br/>
					- Withdraw from an Account -<br/>
					----------------------------<br/>
					Amount to withdraw : 200<br/>
					Beginning a User transaction to withdraw from an account<br/>
					The requested account does not exist!<br/>
					ERROR - org.omg.CORBA.TRANSACTION_ROLLEDBACK:<br/>
					   minor code: 50001  completed: No</font>
				</blockquote>
				<h4>Using a stand-alone Transaction Server</h4>
				<p>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 arjunajts-properties.xml file, to YES. </p>
				<p>In a separate window, the stand-alone Transaction Server is launched as follow:</p>
				<blockquote>
					<font face="Courier New, Courier, mono">java com.arjuna.ats.jts.TransactionServer [-test]</font>
				</blockquote>
				<p>The option <font face="Courier New, Courier, mono">-test</font> allows to see the message "Ready" when the Transaction Server is started.</p>
				<p>The Banking application presented above gives the same output.</p>
			</html>
		</area>
		<area title="Running the example on several machines">
			<html>
				<p>
				It is possible to run the Arjuna Transaction Service and recovery manager processes on a different machine and have clients access these
				centralized services in a hub-and-spoke style architecture.</p>
				<p>
				All that must be done is to provide the clients with enough information to contact the transaction service (such as the ORB's NameService). 
				However, configuring the ORB is beyond the remit of this trailmap and so we shall opt for a simpler mechanism wherby the transaction services
				IOR is shared by access to a common file.</p>
				<p>
				This trailmap stage assumes that the transaction service has been appropriately installed and configured (the 
				<font face="Courier New, Courier, mono">setenv.[bat|sh]</font> script has been ran) onto two hosts (for the purpose of explanation we shall
				refer to these hosts as <font face="Courier New, Courier, mono">host1</font> and <font face="Courier New, Courier, mono">host2</font>).</p>
				<ol>
					<li>Start the transaction service and recovery manager on <font face="Courier New, Courier, mono">host1</font></li>
					<ul>
						<li>Start the recovery manager in one command prompt terminal</li>
					</ul>
					<blockquote>
						<font face="Courier New, Courier, mono">java com.arjuna.ats.arjuna.recovery.RecoveryManager <br/>
									[-test]</font>
					</blockquote>
					<ul>
						<li>Start the transaction service in a second command prompt terminal</li>
					</ul>
					<blockquote>
						<font face="Courier New, Courier, mono">java com.arjuna.ats.jts.TransactionServer [-test]</font>
					</blockquote>
				</ol>
				<ol start="2">
					<li>Share the transaction service IOR on <font face="Courier New, Courier, mono">host1</font> with <font face="Courier New, Courier, mono">host2</font></li>
					<p>
					Open a command prompt on <font face="Courier New, Courier, mono">host2</font> and copy the <font face="Courier New, Courier, mono">CosServices.cfg</font> file 
					from the <font face="Courier New, Courier, mono">&lt;arjunajts_install_root>/etc</font> directory on <font face="Courier New, Courier, mono">host1</font>.</p>
					<p>
					For example, using the popular <font face="Courier New, Courier, mono">scp</font> package, open a shell prompt and issue the following command:</p>
					<blockquote>
						<font face="Courier New, Courier, mono">scp <i>user</i>@<i>host1</i>:&lt;ats_root>/etc/CosServices.cfg &lt;host2_ats_root>/etc/</font>
					</blockquote>

				</ol>
				<ol start="3">
					<li>Start the Bank Server and Bank Client applications on <font face="Courier New, Courier, mono">host2</font></li>
					<p>
					<b>NOTE:</b> <i>See the section above entitled "Using a stand-alone Transaction Server" for more information on how to configure these application to use a remote transaction service.</i></p>

					<ol>
						<li><b>Testing the distributed transaction with <a class="linkscoloured" href="part5_jts_implicit.html"><b>Implicit Propagation Context</b></a></b></li>
					</ol>
					<ul>
						<li>Start the Server</li>
					</ul>
					<pre>   java com.arjuna.demo.jts.remotebank.BankServer</pre>
					<ul>
						<li>In a separate window, start the client</li>
					</ul>
					<pre>   java com.arjuna.demo.jts.remotebank.BankClient</pre>
					<ol start="2">
						<li><b>Testing the distributed transaction with <a class="linkscoloured" href="part5_jts_explicit.html"><b>Explicit Propagation Context</b></a></b></li>
					</ol>
					<ul>
						<li>Start the Server</li>
					</ul>
					<pre>   java com.arjuna.demo.jts.explicitremotebank.BankServer</pre>
					<ul>
						<li>In a separate window, start the client</li>
					</ul>
					<pre>   java com.arjuna.demo.jts.explicitremotebank.BankClient</pre>
				</ol>
			</html>
		</area>
	</content>
	<footer/>
</page>
