|
| WebLogic Server 6.0 Code Examples, BEA Systems, Inc. |
Package examples.jms.trader
This example sends a buy or sell message to a topic from the Java servlet
TraderServlet.
See:
Description
Class Summary |
TraderReceive |
Receives messages and
invokes an EJBean to process them. |
TraderServlet |
Sends a buy or sell message to a topic. |
Package examples.jms.trader Description
This example sends a buy or sell message to a topic from the Java servlet
TraderServlet.
The TraderReceive client receives the messages and
invokes an EJB to process the messages.
A trade limit is set at 500 by
the EJB. Any trades exceeding this value will be reset to 500.
The following sections describe how to:
- Build the example
- Configure the server
- Run the example
- Set up your development shell, as described in
Setting up
your environment.
- Compile the example by executing the following commands or by executing
the build script
provided for this example in
the samples/examples/jms/trader directory. The script will perform the following steps:
- Compile the client as shown in this example for Windows NT/2000:
$ javac -d %CLIENT_CLASSES% TraderReceive.java
- Compile the servlet as shown in this example for Windows NT/2000:
$ javac -d %EX_WEBAPP_CLASSES% TraderServlet.java
The following items have been preconfigured and/or predefined for you:
-
You must choose one or more targets for the JMS server
associated with the topic.
For your convenience, the examplesJMSServer server
has been preconfigured to include the examplesServer as a chosen target.
-
The statelessSession EJB example, invoked by this example,
has been built and deployed.
-
In order to support persistent messaging and durable subscriptions, a
backing store must be configured and assigned to the JMS server.
This example defines a JDBC backing store that uses a Cloudscape Java
database. An evaluation version of Cloudscape is included with WebLogic
Server and a demoPool database is provided.
-
The jmstrader servlet must be deployed as part of a web application
hosted on the WebLogic Server. For your convenience, the jmssender
servlet has been deployed on the examplesWebApp provided.
For more information about deploying a servlet, see
Administration and Configuration
in Programming WebLogic HTTP Servlets.
To configure the server:
-
Start the server with the examples configuration.
-
Bring up the Administration Console in your browser.
-
Click to expand the JMS node in the left pane.
-
Click to expand the Connection Factories node in the left pane.
-
Choose the server target for the exampleTrader connection factory as follows:
-
Select the exampleTrader node.
The exampleTrader connection factory configuration information displays in the
right pane.
-
Select the Targets tab in the right pane to display the Available and Chosen
targets.
-
Move the examplesServer target to the Chosen column and click the Apply button to
save the assignment.
-
If you have configured the server to run
the examples.jms.topic
example, then no additional configuration changes are required to run the
trader example, and you can skip to the section
Run the example.
If you have not configured the server to run the
examples.jms.topic
example, then repeat step 5 to choose the server target for the exampleTopic
connection factory, selecting the exampleTopic node instead of the exampleTrader node.
Run the Example
- With the server running, set up a new development shell
and run the client with the following command:
$ java examples.jms.trader.TraderReceive t3://hostname:port
where:
- hostname
- Host name of the WebLogic Server.
- port
- Port where the WebLogic Server is listening for connections
(weblogic.system.ListenPort).
-
Load the servlet in a browser as follows:
http://hostname:port/examplesWebApp/jmstrader
where:
- hostname
- Host name of the WebLogic Server.
- port
- Port where the WebLogic Server is listening for connections
(weblogic.system.ListenPort).
-
Enter a trade to send and click the Send button. The
TraderReceive client displays messages as
they are received from the topic. In addition, results from the invoked EJB
are displayed in the shell from which the server was started.
A trade limit is set at 500 by
the EJB. Any trades exceeding this value will be reset to 500.
There's More...
For more information about WebLogic JMS, see
Programming
WebLogic JMS.
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.