Professional JMS Programming Read about my latest book on The Java Message Service  ...

 Professional JMS Programming ...  Professional JMS ...

The Stock Trader JMS Application

Gopalan Suresh Raj

 

The Stock Trader Application

To illustrate both Publish-Subscribe and Point-to-Point messaging, let us build a Stock Trader Application. We have a server (represented by the StockServer class) which just keeps sending Stock Quotes to a topic which we call the NASDAQ_Topic. A Subscriber (represented by the Subscriber class) subscribes to this Topic and receives notification of the change in prices of the company stock prices. We also have the Subscriber connected to his stock-broker’s Buy and Sell Queues which are named Buy_Queue and Sell_Queue through a Sender class. The Sender class sends Buy and Sell messages to the appropriate queues as requested by the Subscriber class. The Stock Agents who are responsible for Buying Stocks (represented by the BuyAgent class) and Selling Stocks (represented by the SellAgent class) are subscribed to the Buy_Queue and the Sell_Queue respectively. The whole scenario is depicted in Figure. We use Publish-Subscribe messaging between the StockServer and the Subscriber. We use Point-to-Point or Queue based messaging between the Sender and the BuyAgent and SellAgent classes.

To implement the following example, I used a beta version of Fiorano Software, Inc.’s Fiorano/EMS Lite for Windows NT, JMS implementation. You can download this implementation from Fiorano Software, Inc. at http://www.fiorano.com/ and set it up according to instructions.

Figure 1: Our Stock Trader Implementation

Before we go ahead coding away to glory, we need to set up our Topics and queues. Run the administrator console. Move to the Topics tab and create a Topic called Nasdaq_Topic as shown in Figure 2.

Figure 2: Using the Administrator console to set up the Topic

Move over to the Queues tab and create both a Sell_Queue and a Buy_Queue as shown in Figure 3.

Figure 3: Using the Administrator console to set up the Queues

 

Developing a Topic Publisher - The Stock Server

Developing a Topic Subscriber - The Stock Subscriber

Developing a Queue Sender - The Stock Buyer

Developing a Queue Receiver - The Stock Buy/Sell Agent

 

Author Bibliography
Gopalan Suresh Raj is a Software Architect, Developer and an active Author. He is contributing author to a couple of books "Enterprise Java Computing-Applications and Architecture" and "The Awesome Power of JavaBeans". His expertise spans enterprise component architectures and distributed object computing. Visit him at his Web Cornucopia© site (http://www.execpc.com/~gopalan) or mail him at gopalan@execpc.com.

click here to go to
My Java Message Service (JMS) HomePage...


Go to the Component Engineering Cornucopia page

This site was developed and is maintained by Gopalan Suresh Raj

This page has been visited times since September 24,1999.

Last Updated : Sept 24, '99

If you have any questions, comments, or problems regarding this site, please write to me I would love to hear from you.


Copyright (c) 1997-99, Gopalan Suresh Raj - All rights reserved. Terms of use.

All products and companies mentioned at this site are trademarks of their respective owners.