} }

 Files   Prepare   Run   Troubleshooting   Related Topics 

 

About the Example

This example shows how to send JMS messages using a Java servlet.


 

Files Used in the Example

Directory Location:

MW_HOME/wlserver_10.3/samples/server/examples/jms/sender/

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

File

Click source files to view code.

Description

build.xml Ant build file that contains targets for building and running the example.
SenderServlet.java Servlet to run example.

 

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

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

No special configuration is required for this example because the weblogic.examples.jms.QueueConnectionFactory and exampleTopic Connection Factories are preconfigured. To verify that the Connection Factoies are configured and deployed, follow the steps below:

To configure Oracle WebLogic Server:

  1. Bring up the Administration Console in your browser.
  2. In the Domain Structure view in the left pane, select Services > Messaging > JMS Modules.
  3. Select the examples-jms module from the table of JMS Modules.
  4. Observe that the weblogic.examples.jms.QueueConnectionFactory and exampleTopic are targeted to the examplesServer and the Subdeployment is configured as Default Targetting (which is the recommended setting for Connection Factories).
  5. Click the General tab to display general configuration paramters.
  6. You can view the configuration by clicking the weblogic.examples.jms.QueueConnectionFactory or exampleTopic Connection Factory instance.

 

Build and Deploy the Example

  1. Set up your development shell, as described in Setting up your environment.
  2. Execute the following command from the shell where you set your environment:

    ant build

    This command compiles and stages the example. The Ant command uses the build.xml file, located in the SAMPLES_HOME\server\examples\src\examples\jms\sender directory, to build the example.

    The script will compile the SenderServlet, as shown in this example for a Windows system:

      prompt> javac -d %EX_WEBAPP_CLASSES% SenderServlet.java

    and copy the file to the following directory: SAMPLES_HOME\server\examples\build\examplesWebApp\WEB-INF\classes\examples\jms\sender


 

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 will load the servlet in a browser using the following URL:
      http://hostname:port/examplesWebApp/SenderServlet
    where:
    hostname
    refers to the machine on which Oracle WebLogic Server is running
    port
    refers to the port on which Oracle WebLogic Server is listening for connections
  3. Enter a message to send and click the Send Message button.
  4. You can use the QueueReceive and TopicReceive examples to observe messages being sent to the queue and topic, respectively, based on the destination selected. For a queue, persistent messages will be sent even if the queue is not connected to the server and listening at the time the messages are sent.

 

Troubleshooting


 

Related Topics

(Internet connection required.)