WebLogic Server 6.0 Code Examples, BEA Systems, Inc.

examples.jms.startup
Class ServerReceive

java.lang.Object
  |
  +--examples.jms.startup.ServerReceive
All Implemented Interfaces:
javax.jms.MessageListener, weblogic.common.T3StartupDef

public class ServerReceive
extends java.lang.Object
implements javax.jms.MessageListener, weblogic.common.T3StartupDef

This example establishes a single message listener. As messages are received from the topic, they are displayed in the shell running the WebLogic Server and written to the weblogic.log file. You can use the TopicSend client to send messages to the topic.

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 command or by executing the build script provided for this example in the samples/examples/jms/startup directory. The script will perform the following step:

    Compile the ServerReceive as shown in this example for Windows NT/2000:

      $ javac -d %SERVER_CLASSES% ServerReceive.java

Configure the Server

The WebLogic startup class has been preconfigured for your convenience. You must deploy the startup class on the server, as described in the following procedure.

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 Deployments node in the left pane.
  4. Click to expand the Startup & Shutdown node in the left pane.
  5. Choose the server target for the serverReceive startup class as follows:
    1. Select the serverReceive node. The serverReceive startup class 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.
    Note: If you have configured the server to run the examples.jms.topic example, then no additional configuration changes are required to run the ServerReceive example. You can skip to the section Run the Example.
  6. Click to expand the JMS node in the left pane.
  7. Click to expand the JMS Connection Factories node in the left pane.
  8. 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.

    Note: Normally, you would also have to choose one or more targets for the JMS server associated with the topic. For your convenience, the examplesJMSServer server has been preconfigured to include the examplesServer as a chosen target.

Run the Example

  1. Restart the server to invoke the startup class.
  2. Start the TopicSend client in your development shell and send messages to the topic. The ServerReceive startup class displays messages in the shell running WebLogic Server and writes them to the weblogic.log file as they are received from the topic.

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

Constructor Summary
ServerReceive()
           
 
Method Summary
 void onMessage(javax.jms.Message msg)
          Message listener interface.
 void setServices(weblogic.common.T3ServicesDef services)
          Passes to the startup class the handle of an object that can be used to access WebLogic services.
 java.lang.String startup(java.lang.String name, java.util.Hashtable args)
          Creates a consumer.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerReceive

public ServerReceive()
Method Detail

onMessage

public void onMessage(javax.jms.Message msg)
Message listener interface.
Specified by:
onMessage in interface javax.jms.MessageListener
Parameters:
msg - message

setServices

public void setServices(weblogic.common.T3ServicesDef services)
Passes to the startup class the handle of an object that can be used to access WebLogic services. This makes another reference to the services object so it can be used later.
Specified by:
setServices in interface weblogic.common.T3StartupDef
Parameters:
services - services stub

startup

public java.lang.String startup(java.lang.String name,
                                java.util.Hashtable args)
                         throws java.lang.Exception
Creates a consumer.
Specified by:
startup in interface weblogic.common.T3StartupDef
Parameters:
name - name
args - environment
Throws:
java.lang.Exception - if problem occurs

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

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