Chapter 23
904
The PurchaseOrder Class
Here is the PurchaseOrder class:
package JMSExample;
class PurchaseOrder implements java.io.Serializable
{
private String stockSymbol = null;
private int stockQuantity = 0;
public PurchaseOrder(String stockSymbol, int stockQuantity)
{
this.stockSymbol = stockSymbol;
this.stockQuantity = stockQuantity;
}
public String stockSymbol()
{
return stockSymbol;
}
public int stockQuantity()
{
return stockQuantity;
}
}
Running the JMS Example
If you have not already run the examples earlier in the chapter you need to set up your server and your
environment variables as described in the sections on running the other examples. Compile the two files
StockGuy.java and PurchaserGuy.java. Then, configure both the PurchaseOrdersQueue and
the StockQuotesTopic.
Once you set up the queue and the topic and compile the code, you can run the two programs at once.
First, start up the PurchaserGuy. Choose which stock symbols you wish to receive, then type d for
done entering stock quotes: