|
|
| WebLogic Server 7.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.
-
Build the example by executing the Java ant command.
The Java ant command uses the
build.xml file in the SAMPLES_HOME\server\src\examples\jms\trader
directory, where SAMPLES_HOME refers to the
directory for all samples and examples for the WebLogic Platform.
prompt> ant
The Java ant command builds the example and copies the files to the following directories:
- Client reciever: SAMPLES_HOME\server\stage\examples\clientclasses\examples\jms\trader
- Servlet sender: SAMPLES_HOME\server\stage\examples\examplesWebApp\WEB-INF\classes\examples\jms\trader
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 Pointbase Java
database. An evaluation version of Pointbase 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:
prompt> ant run
Parameters contained within the run script are:
- hostname
- Host name of the WebLogic Server.
- port
- Port where the WebLogic Server is listening for connections.
-
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.
-
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 © 2002 BEA Systems, Inc. All Rights Reserved.