
We will use this sample to demonstrate the capabilities of Tungsten, highlighting the ease of integration of quality of service modules. In the context of this trading scenario, the use of security and reliable messaging is emphasized on.
Trading on the stock/share market involves three parties-stock exchange, trader (stock broker) & client (shareholder). A shareholder who buys and sells shares on the stock market needs to do so through a stock broker or trader, in which case he would first need to become a client of that particular trader. The shareholder uses his Central Depository System (CDS) account which registers him with the stock exchange to sell & buy shares on the stock market. A trader can register client with the stock exchange.
In this sample we only consider services offered by trader to client for the sake of simplicity & ease of understanding.
The following section describes these services in detail.
In this sample we only consider the scenario where client gets the stock symbol from the Trader and lists them. Using this symbol client gets stock quotes from Trader.

Note: attributes of Stock Quote -name, symbol, selling price, high price, low price
SimpleTrader sample is in TUNGSTEN_HOME|samples|SimpleTrader. This sample emulates a simple stock trader, where you can get the stock symbols and the stock quote for a particular stock symbol. In this case the stocks are elements in the periodic table, and their symbols are their chemical element symbols.
To build the samples you need the Apache Ant build tool.
cd TUNGSTEN_HOME\samples\SimpleTrader
ant
Buildfile: build.xml clean: init: [mkdir] Created dir: C:\tungsten-\samples\SimpleTrader\temp [mkdir] Created dir: C:\tungsten-1.0\samples\SimpleTrader\temp\classes [some lines deleted here] build-all: [echo] Copying the created aar files in to the repository [copy] Copying 1 file to C:\tungsten-1.0\repository\services BUILD SUCCESSFUL Total time: 11 seconds
The build automatically copies the .aar file containing the service into the repository.
(See Administrator’s Guide on how to sign into Management Console and to navigate through it.)
On MS Windows:
run-client.bat [ -qos (rm|secure|securerm)] [ -te traderServiceURL]
On Unix/Linux:
run-client.sh [ -qos (rm|secure|securerm)] [ -te traderServiceURL]
Terms used:
Note: In the secure and securerm cases, in order to enable Username Token Authentication, you must add at least one user and/or role to the Trader service, after engaging the rampart module.
From SimpleTrader directory type:
$ sh run-client.sh
You should see:
Using following as parameters TraderService URL : http://localhost:9762/axis2/services/Trader STARTING TRADE SAMPLE CLIENT ============================= Please select your operation... --------------------------------- (1) getQuote (2) getSymbols (3) Exit
From SimpleTrader directory type:
$ sh run-client.sh -qos secure
You would see a prompt asking for the username and password as follows:
Using following parameters
TraderService URL : http://localhost:9762/axis2/services/Trader
QOS : secure
STARTING TRADE SAMPLE CLIENT
=============================
Enabling UsernameToken authentication...
Please enter your username :
test
Please enter your password :
test
Please make sure you enable UsernameToken authentication for the Trader service.
This can be done by first engaging the security module to the Trader service
and then assigning a user or a role to the service.
From SimpleTrader directory type:
$ sh run-client.sh -qos rm -te http://127.0.0.1:9762/axis2/services/Trader
or
$ sh run-client.sh -qos rm
Populating the stock market ................Done. Using following parameters TungstenHome = ../.. TraderService URL = http://127.0.0.1:9762/axis2/services/Trader STARTING TRADE SAMPLE CLIENT ============================= Please select your operation... --------------------------------- (1) getQuote (2) getSymbols (3) Exit :1 ...Getting Quote... Please enter the symbol:mn Please select your operation... --------------------------------- (1) getQuote (2) getSymbols (3) Exit :Printing stock quote... mn Manganese 14.0 28.0 0.0
From SimpleTrader directory type:
$ sh run-client.sh -qos securerm
As you will be able to see, with the rm option, the time to receive the response for the very first request will be comparatively larger. This is due to the control messages that are sent initially, in order to estrablish the reliable messaging channel.
Try playing around with the above options and see how it works for yourself!