Files   Prepare   Run   Troubleshooting   Related Topics 

About the Example

This example is a stock information system simulated application, including two standalone publishers and a embedded publisher running in Web module which are responsible for generating simulated trade information and pubishing the information to WebLogic HTTP Pub/Sub Server, and a Web module to service the requests from user's browsers to provide the stock trade information published by the client.

The example demonstrates the usage of the WebLogic HTTP Pub/Sub Server utilizing the Dojo Toolkits which provides the support of Bayeux protocol.

After you run the example, a page including a stock table and a chart will be displayed in your browser. Select the stock that you would like to view from the list box and click "Subscribe" button could add the stock to the table, click the "X" icon at the end of row of the stock will remove the stock from table and click the checkbox at the beginning of the row of the stock will add/remove the stock to/from the chart below.


Files Used in the Example

Directory Location:

BEA_HOME/wlserver_10.3/samples/server/examples/webapp/pubsub/stock/

(where BEA_HOME is the directory containing your WebLogic Server installation)

File

Click source files to view code.

Description

application.xml The J2EE standard enterprise application deployment descriptor.
build.xml Ant build file that contains targets for building and running the example.
createUsers.py WLST script used to create users for this example.
web.xml Web application deployment descriptor.
weblogic.xml The WebLogic Server-specific Web application deployment descriptor.
weblogic-pubsub.xml The WebLogic HTTP Pub/Sub Server deployment descriptor.
weblogic-pubsub.xml The WebLogic HTTP Pub/Sub Server deployment descriptor using the JMS Handler.
index.jsp The JSP file for displaying the stock table and chart.
publisher.jsp The JSP file for starting and stopping the publisher running in the Web module.
DataProviderServlet.java The servlet which provides the list of stock symbols that matched the passed parameter.
ApiBasedClient.java The Client implementation which publishes messages through Pub/Sub server side APIs.
InWebPublisher.java The Publisher running in the Web module.
InWebPublisherControllerServlet.java The servlet initializing the InWebPublisher.
SymbolsProvider.java The class which provides the list of available stock symbols.
Client.java The interface of client.
TradeSimulator.java The class simulating the stock trade information.
AbstractPublisher.java The abstract class for all publishers.
HttpBasedClient.java The Client implementation which publishes messages through HTTP protocol.
JmsBasedClient.java The Client implementation which publishes messages through JMS topic.
StandalonePublisher.java The main class which invokes HttpBasedClient or JmsBasedClient to publish messages to server.

Prepare the Example

Prerequisites

Before working with this example:

  1. Install WebLogic Server, including the examples.
  2. Start the Examples server.
  3. Set up your environment.

Configure WebLogic Server

Build and Deploy the Example

To build the example, follow these steps:

  1. Change to the SAMPLES_HOME\server\examples\src\examples\webapp\pubsub\stock directory, where SAMPLES_HOME refers to the main WebLogic Server examples directory, such as d:\bea\wlserver_10.3\samples.
  2. Execute the following command:

    ant build

    This command compiles and stages the example.
  3. WebLogic HTTP Pub/Sub Server supports two kinds of Handler, one is Default Handler and the other is JMS Handler, JMS Handler will map the channels to JMS topics.

    By default this example will use the Default Handler, you can switch to JMS Handler by setting entironment variable "USE_JMS_HANDLER" to "true" before executing "ant build". The topics that used by JMS Handler has been pre-created in the example domain.

  4. Execute the following command:

    ant deploy

    This command deploys the example on the wl_server domain of your WebLogic Server installation.

    This command also creates the following users in the domain if they don't exist.

    UsernamePassword
    PublisherPublisher
    SubscriberSubscriber

    The Ant command uses the build.xml file, located in the SAMPLES_HOME\server\examples\src\examples\webapp\pubsub\stock directory, to build the example.

Run the Example

  1. Complete the steps in the "Prepare the Example" section.
  2. Execute the following command from the shell where you set your environment:

    ant run

    This command runs the example.

    A browser window will open. Login as user Subscriber, in the browser, the stock table and chart will displayed and you can select your favorite stocks.

  3. Execute the following command from the shell where you set your environment:

    ant publisher.run

    You will not see any trade information before execute this command, as we have mentioned there are some publishers to generate the simulated trade information, this command is for launching the default publisher.

  4. Other publishers


  5. ant inweb.publisher.run

    This command will open a web page on which you can start or stop the Publisher running in the Web module. To start or stop the publisher you must login as user Publisher.

    ant jms.publisher.run

    If you are using JMS handler, you can also use this command to launch the Publisher which publish messages to Pub/Sub server through a JMS topic.

    Note: Don't run more than one publisher at one time.



Troubleshooting


Related Topics

(Internet connection required.)


Copyright © 1996, 2008, Oracle and/or its affiliates. All Rights Reserved.