AppendixRunning the Stock Trader

Enterprise Java
Guarantee Inter-Enterprise Message Delivery Using JMS
Gopalan Suresh Raj
Appendix
Running the Stock Trader
The partial screen dumps are shown below:

  1. Compile and run the StockServer.

    
    E:\com\gopalan\StockMarket\StockServer>
    E:\com\gopalan\StockMarket\StockServer>
    E:\com\gopalan\StockMarket\StockServer>javac StockServer.java
    E:\com\gopalan\StockMarket\StockServer>java StockServer
    Creating topic connection
    Creating topic session: not transacted, auto ack
    Creating a topic publisher
    NASDAQ: Value of SUNW= $100.0
    NASDAQ: Value of MSFT= $99.0
    NASDAQ: Value of CPWR= $98.0
    
    NASDAQ: Value of SUNW= $97.0
    NASDAQ: Value of MSFT= $96.0
    NASDAQ: Value of CPWR= $95.0
    
  2. Compile and run the BuyAgent.

    
    E:\com\gopalan\StockMarket\StockAgent>javac BuyAgent.java
    E:\com\gopalan\StockMarket\StockAgent>java BuyAgent
    Creating Queue connection
    Creating Queue session: not trans, auto ack
    Creating Queue Receiver
    Execute Job : Customer ID :Athul. Buy 1000 stocks of MSFT at $9.0
    Execute Job : Customer ID :Athul. Buy 1000 stocks of CPWR at $8.0
    Execute Job : Customer ID :Athul. Buy 1000 stocks of SUNW at $7.0
    Execute Job : Customer ID :Athul. Buy 1000 stocks of MSFT at $6.0
    Execute Job : Customer ID :Athul. Buy 1000 stocks of CPWR at $5.0
    
  3. Compile and run the SellAgent.

    
    E:\com\gopalan\StockMarket\StockAgent>javac SellAgent.java
    E:\com\gopalan\StockMarket\StockAgent>java SellAgent
    Creating Queue connection
    Creating Queue session: not trans, auto ack
    Creating Queue Receiver
    Execute Job : Customer ID : Athul. Sell 100 stocks of SUNW at $100.0
    Execute Job : Customer ID : Athul. Sell 100 stocks of MSFT at $99.0
    Execute Job : Customer ID : Athul. Sell 100 stocks of CPWR at $98.0
    
  4. Compile Subscriber.java and Sender.java and run the Subscriber with the customerID as a parameter in the command line.

    
    E:\com\gopalan\StockMarket\Subscriber>
    E:\com\gopalan\StockMarket\Subscriber>javac Subscriber.java
    E:\com\gopalan\StockMarket\Subscriber>javac Sender.java
    E:\com\gopalan\StockMarket\Subscriber>java Subscriber Athul
    Creating topic connection
    Creating topic session: not transacted, auto ack
    Creating topic, subscriber
    Ready to subscribe for messages :
    Creating Queue connections
    Creating queue session: not transacted, auto ack
    Creating Queue, senders
    Received : nasdaq: Value of SUNW = $91.0
    Received : nasdaq: Value of MSFT = $90.0
    Received : nasdaq: Value of CPWR = $89.0
    
    
    Received : nasdaq: Value of SUNW = $88.0
    Received : nasdaq: Value of MSFT = $87.0
    Received : nasdaq: Value of CPWR = $86.0