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:

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

    1. Compile the client as shown in this example for Windows NT/2000:

        $ javac -d %CLIENT_CLASSES% TraderReceive.java

    2. Compile the servlet as shown in this example for Windows NT/2000:

        $ javac -d %EX_WEBAPP_CLASSES% TraderServlet.java

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:
      $ 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).

  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 (weblogic.system.ListenPort).

  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/docs60

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