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:

  1. Build the example
  2. Configure the server
  3. Run the example

Build the Example

  1. Set up your development shell, as described in Setting up your environment.

  2. 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:

Configure the Server

The following items have been preconfigured and/or predefined for you:

To configure the server:

  1. Start the server with the examples configuration.
  2. Bring up the Administration Console in your browser.
  3. Click to expand the JMS node in the left pane.
  4. Click to expand the Connection Factories node in the left pane.
  5. Choose the server target for the exampleTrader connection factory as follows:
    1. Select the exampleTrader node. The exampleTrader connection factory configuration information displays in the right pane.
    2. Select the Targets tab in the right pane to display the Available and Chosen targets.
    3. Move the examplesServer target to the Chosen column and click the Apply button to save the assignment.
  6. 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

  1. 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.

  2. 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.

  3. 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.


Documentation is available at
http://e-docs.bea.com/wls/docs70

Copyright © 2002 BEA Systems, Inc. All Rights Reserved.