WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

Package examples.jms.drawdemo

This graphical example illustrates key concepts of the JMS publish/subscribe model.

See:
          Description

Class Summary
JMSDrawDemo This graphical example illustrates key concepts of the JMS publish/subscribe model.
 

Package examples.jms.drawdemo Description

This graphical example illustrates key concepts of the JMS publish/subscribe model. Run the example to observe the behavior of transacted sessions, persistent messages, and durable subscribers.

Each JMSDrawDemo instance displays a canvas. When you click on a canvas, an icon is placed at that location and the mouse coordinates are published in a message and delivered to the JMS topic. When other instances of the application receive a message from the topic, they display an icon at the specified coordinates. As you click on one canvas, the other canvasses duplicate the arrangement of icons.

This graphical example illustrates key concepts of the JMS publish/subscribe model. Run the example to observe the behavior of transacted sessions, persistent messages, and durable subscribers.

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\drawdemo 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 directory:
    SAMPLES_HOME\server\stage\examples\clientclasses\examples\jms\drawdemo

Configure the Server

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

Note: If you have configured the server to run the examples.jms.topic example, then no additional configuration changes are required to run the JMSDrawDemo example, and you can skip to the section Run the Example.

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 JMS Connection Factories node in the left pane.
  5. Choose the server target for the exampleTopic connection factory as follows:
    1. Select the exampleTopic node. The exampleTopic 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.

Run the example

  1. Start the server with the examples configuration (if it is not already started).
  2. Set up two or more development shells your environment and start the JMSDrawDemo application in each shell 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.

If you want each client window that you open to be unique, then you need to add a DurableSubscriberID . The durable subscriber ID allows you to try out persistence with durable subscribers. Each instance of the application must have a unique durable subscriber ID.

To do this, add a unique name after the URL in the run command inside the build.xml file. You must do this for every unique window that you open (you will see that name in the frame of the client window). So, for example, if you want to name the client "dilbert", you can change the build.xml run command to look like this:

<java classname="examples.jms.drawdemo.JMSDrawDemo" fork="yes" failonerror="true">
<arg line="t3://localhost:${PORT} dilbert">

Once it's running, the JMSDrawDemo application displays a command panel at the bottom of the window that allows you to:

Select the Persistent check box to enable persistent messaging. Persistent messages are of most interest to durable subscribers. You can establish a durable subscription by specifying the (optional) durable subscriber ID as the second argument on the command line. Select the Persistent check box to enable persistent JMS messages. Persistent messages that are sent when the subscriber is not active will be delivered when the subscriber reattaches--even after a WebLogic Server reboot.

Select the Transacted check box to turn on transacted mode. When the transacted mode is on, JMS does not send messages until you click the Commit button to commit the transaction, or click Rollback to roll back the transaction. To view a transaction commit operation, click several times on one canvas, then click Commit. The other canvasses are updated only after you click Commit.

Click Clear to send a clearScreen message to the topic. When the message is delivered, all instances of the application clear their canvasses.

Click Quit to quit the application.

There's More...

For more information on WebLogic JMS, refer to Programming WebLogic JMS.


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

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