} }

 Files   Prepare   Run   Troubleshooting   Related Topics 

 

About the Example

This example is a simulated stock information system application. It includes two standalone publishers and an embedded publisher running in a Web module that are responsible for generating simulated trade information and publishing the information to WebLogic HTTP Pub/Sub Server, and a Web module to service the requests from users' 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 the 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 the "Subscribe" button to add the stock to the table. Click the "X" icon at the end of row of the stock to remove the stock from the table. Select the checkbox at the beginning of the row of the stock to add/remove the stock to/from the chart below.


 

Files Used in the Example

Directory Location:

MW_HOME/wlserver_10.3/samples/server/examples/src/examples/webapp/pubsub/stock/

(where MW_HOME is the directory containing your Oracle WebLogic Server installation)

File

Click source files to view code.

Description

application.xml 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 Oracle WebLogic Server-specific Web application deployment descriptor.
weblogic-pubsub.xml WebLogic HTTP Pub/Sub Server deployment descriptor.
weblogic-pubsub.xml WebLogic HTTP Pub/Sub Server deployment descriptor using the JMS Handler.
index.jsp JSP file for displaying the stock table and chart.
publisher.jsp JSP file for starting and stopping the publisher running in the Web module.
DataProviderServlet.java Servlet which provides the list of stock symbols that matched the passed parameter.
ApiBasedClient.java Client implementation which publishes messages through Pub/Sub server side APIs.
InWebPublisher.java Publisher running in the Web module.
InWebPublisherControllerServlet.java Servlet initializing the InWebPublisher.
SymbolsProvider.java Class which provides the list of available stock symbols.
Client.java Interface of client.
TradeSimulator.java Class simulating the stock trade information.
AbstractPublisher.java Abstract class for all publishers.
HttpBasedClient.java Client implementation which publishes messages through HTTP protocol.
JmsBasedClient.java Client implementation which publishes messages through JMS topic.
StandalonePublisher.java Main class which invokes HttpBasedClient or JmsBasedClient to publish messages to server.

 

Prepare the Example

 

Prerequisites

Before working with this example:

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

 

Configure Oracle WebLogic Server

  No special configuration is required for this example.

 

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 Oracle WebLogic Server examples directory, such as d:\Oracle\Middleware\wlserver_10.3\samples.
  2. Execute the following command from the shell where you set your environment:

    ant build

    This command compiles and stages the example.

    WebLogic HTTP Pub/Sub Server supports two kinds of handler: the default handler and the JMS handler. The JMS handler maps the channels to JMS topics.

    By default, this example will use the default handler. You can switch to the JMS handler by setting the environment variable "USE_JMS_HANDLER" to "true" before executing "ant build". The topics used by JMS handler are created in the example domain.
  3. Execute the following command from the shell where you set your environment:

    ant deploy

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

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

    Username Password
    Publisher Publisher
    Subscriber Subscriber

    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 opens. Log in as user Subscriber in the browser. The stock table and chart are 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 prior to executing this command. As previously described, the example includes publishers to generate the simulated trade information. This command launches the default publisher.

  4. To launch other publishers:

    ant inweb.publisher.run

    This command opens a Web page on which you can start or stop the publisher running in the Web module. To start or stop the publisher log in as user Publisher. ant jms.publisher.run

    If you are using the JMS handler, you can also use this command to launch the publisher, which publishes messages to Pub/Sub server through a JMS topic.
    Note: Do not run more than one publisher at a time.

 

Troubleshooting


 

Related Topics

(Internet connection required.)