站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > The J2EE 1.4 Tutorial

Deploying and Running SimpleMessageApp - The J2EE 1.4 Tutorial

Deploying and Running SimpleMessageApp

To deploy and run this example, go to the <INSTALL>/j2eetutorial14/examples/ejb/simplemessage directory.

Creating the Administered Objects

This example requires the following:

  • A JMS connection factory resource
  • A JMS destination resource
  • A physical destination to which the destination resource refers

If you have run the simple JMS examples in Chapter 33 and have not deleted the resources, you already have these resources and do not need to perform these steps.

To start the Admin Console, follow the instructions in Starting the Admin Console.

To create the connection factory, perform the following steps:

  1. In the tree component, expand the Resources node, then expand the JMS Resources node.
  2. Select the Connection Factories node.
  3. On the JMS Connection Factories page, click New. The Create JMS Connection Factory page appears.
  4. In the JNDI Name field, type jms/ConnectionFactory.
  5. Choose javax.jms.ConnectionFactory from the Type combo box.
  6. Select the Enabled checkbox.
  7. Click OK.

To create the physical destination, perform the following steps:

  1. In the tree component, expand the Resources node, then expand the JMS Resources node.
  2. Select the Physical Destinations node.
  3. On the Physical Destinations page, click New. The Create Physical Destination page appears.
  4. In the Physical Destination Name field, type PhysicalQueue.
  5. Choose queue from the Type combo box.
  6. Click OK.

To create the destination resource and link it to the physical destination, perform the following steps:

  1. In the tree component, expand the Resources node, then expand the JMS Resources node.
  2. Select the Destination Resources node.
  3. On the JMS Destination Resources page, click New. The Create JMS Destination Resource page appears.
  4. In the JNDI Name field, type jms/Queue.
  5. Choose javax.jms.Queue from the Type combo box.
  6. Select the Enabled checkbox.
  7. In the Additional Properties area, type PhysicalQueue in the Value field for the Name property.
  8. Click OK.

Deploying the Application

  1. In deploytool, open the SimpleMessageApp.ear file, which resides in this directory:
  2. <INSTALL>/j2eetutorial14/examples/ejb/provided-ears/

  3. Deploy the SimpleMessageApp application.
  4. In the Deploy Module dialog box:
    1. Select the Return Client JAR checkbox.
    2. In the field below the checkbox, enter the following:
    3. <INSTALL>/j2eetutorial14/examples/ejb/simplemessage

Running the Client

After you deploy the application, you run the client as follows:

  1. In the directory <INSTALL>/j2eetutorial14/examples/ejb/simplemessage, type the following command on a single line:
  2. appclient -client SimpleMessageAppClient.jar

  3. The client displays these lines:
  4. Sending message: This is message 1
    Sending message: This is message 2
    Sending message: This is message 3
    To see if the bean received the messages,
    check <install_dir>/domains/domain1/logs/server.log.

  5. In the server log file, the following lines should be displayed, wrapped in logging information:
  6. MESSAGE BEAN: Message received: This is message 1
    MESSAGE BEAN: Message received: This is message 2
    MESSAGE BEAN: Message received: This is message 3

Undeploy the application after you finish running the client.

Removing the Administered Objects

After you run the example, you can use the Admin Console to delete the connection factory and queue. These resources are needed for the JMS examples in Chapters 33 and 34, however, so if you plan to run those examples, do not delete the resources.