All Examples  This Package  JMS Examples

Class examples.jms.drawdemo.JMSDrawDemo

examples.jms.drawdemo.JMSDrawDemo

public class JMSDrawDemo
This example is graphical illustration of some key concepts of the JMS publish/subscribe model. With it, you can see the behavior of transacted sessions, persistent messages, and durable subscribers.

Configure the server:

  1. If you want to try the persistent and durable subscriber features, make sure you have defined a JMS connection pool in your weblogic.properties file as described in About this package.

Build the example:

  1. Set up your development shell, as described in Setting up your environment.
  2. Compile the file in this directory as shown in this examples for Windows NT:
      $ javac -d %CLIENT_CLASSES% JMSDrawDemo.java

Run the example:

  1. Start the WebLogic Server in a new command shell.
  2. Start the JMSDrawDemo application in two or more development shells with the following command. Do not forget to set up new development shells, as described in Setting up your environment.
      $ java examples.jms.drawdemo.JMSDrawDemo t3://hostname:port [DurableSubID]
    where:
    hostname
    Host name of the WebLogic Server
    port
    Port where the WebLogic Server is listening for connections (weblogic.system.ListenPort).
    DurableSubID
    Include the Durable Subscriber ID to try out persistence with Durable Subscribers. Each instance of the application must have a unique Durable Subscriber ID.

Each JMSDrawDemo instance displays a canvas. A click of the mouse on a canvas publishes the mouse coordinates in a message 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 others duplicate the arrangement of icons.

The JMSDrawDemo application has buttons and checkboxes that send commands or or change various parameters. If you click the Clear button, the application sends a clearScreen message to the Topic. When the message is delivered, all instances of the application clear their canvasses.

Check the Transacted checkbox to turn on "transacted" mode. When the transacted mode is on, JMS does not send messages until you click the Commit button. Or click the Rollback button to roll back the transaction. To view a commit graphically, click several times on the canvas, then click the Commit button. Other canvasses do not update until you commit.

Persistent messages are of most interest to durable subscribers. By running this example with an (optional) durable subscriber name as the second argument, a durable subscription is established. Check the Persistent checkbox to enable persistent JMS messages. Persistent messages sent when the subscriber is not active will be delivered when the subscriber reattaches, even after rebooting the WebLogic Server.

Author:
Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.

Variable Index

 o IMAGE
 o JMS_FACTORY
 o JNDI_FACTORY
 o TOPIC

Constructor Index

 o JMSDrawDemo(JFrame, String, String)
CONSTRUCTOR - Initialize the user interface & JMS objects

Method Index

 o actionPerformed(ActionEvent)
ActionListener - Respond to button presses
 o getPreferredSize()
 o imageUpdate(Image, int, int, int, int, int)
 o loadImage(String)
Image Loading Utilities
 o main(String[])
MAIN
 o mouseClicked(MouseEvent)
 o mouseEntered(MouseEvent)
 o mouseExited(MouseEvent)
 o mousePressed(MouseEvent)
Mouse Listener - respond to Mouse Events
 o mouseReleased(MouseEvent)
The user has clicked in the canvas.
 o onMessage(Message)
Receive a JMS message with X/Y coordinates, or a "clearScreen" message
 o paint(Graphics)
Paint the user interface.

Variables

 o JNDI_FACTORY
 public static final String JNDI_FACTORY
 o JMS_FACTORY
 public static final String JMS_FACTORY
 o TOPIC
 public static final String TOPIC
 o IMAGE
 public static final String IMAGE

Constructors

 o JMSDrawDemo
 public JMSDrawDemo(JFrame frame,
                    String url,
                    String durableSubscriberID) throws NamingException, JMSException
CONSTRUCTOR - Initialize the user interface & JMS objects

Methods

 o onMessage
 public void onMessage(Message msg)
Receive a JMS message with X/Y coordinates, or a "clearScreen" message

 o paint
 public void paint(Graphics g)
Paint the user interface.

 o getPreferredSize
 public Dimension getPreferredSize()
 o mousePressed
 public void mousePressed(MouseEvent e)
Mouse Listener - respond to Mouse Events

 o mouseClicked
 public void mouseClicked(MouseEvent e)
 o mouseEntered
 public void mouseEntered(MouseEvent e)
 o mouseExited
 public void mouseExited(MouseEvent e)
 o mouseReleased
 public void mouseReleased(MouseEvent e)
The user has clicked in the canvas. Send an event with the mouse coordinates (as a scaled percentage of the screen size)

 o actionPerformed
 public void actionPerformed(ActionEvent ev)
ActionListener - Respond to button presses

 o loadImage
 public Image loadImage(String resourceName)
Image Loading Utilities

 o imageUpdate
 public boolean imageUpdate(Image image,
                            int infoFlags,
                            int x,
                            int y,
                            int width,
                            int height)
 o main
 public static void main(String argv[]) throws NamingException, JMSException
MAIN


All Examples  This Package  JMS Examples