Packaging, Deploying, and Running SimpleMessage
To package, deploy and run this example, go to the
<
INSTALL
>/javaeetutorial5/examples/ejb/simplemessage
directory.Creating the Administered Objects
This example requires the following:
If you have run the simple JMS examples in Chapter 32 and have not deleted the resources, you already have these resources and do not need to perform these steps.
You can use Ant targets to create the resources. The Ant targets, which are defined in the
build.xml
file for this example, use theasadmin
command. To create the resources needed for this example, use the following commands:
Note: The first time you run a command that creates JMS resources, the command may take a long time because the Application Server is initializing the JMS provider.
These commands do the following:
The Ant targets for these commands refer to other targets that are defined in the file
<
INSTALL
>/javaeetutorial5/examples/bp-project/app-server-ant.xml
.Creating and Packaging the Application
To create and package the application, use the default target for the
build.xml
file:This target packages the application client and the message-driven bean, then creates a file named
simplemessage.ear
in thedist
directory.By using resource injection and annotations, you avoid having to create deployment descriptor files for the message-driven bean and application client. You need to use deployment descriptors only if you want to override the values specified in the annotated source files.
Deploying the Application
To deploy the application, use the following command:
Ignore the message that states that the application is deployed at a URL.
To return a client JAR file, use the following command:
This command returns a JAR file named
simplemessageClient.jar
in theclient-jar
directory.Running the Client
After you deploy the application, you run the client as follows:
- In the directory
<
INSTALL
>/javaeetutorial5/examples/ejb/simplemessage
, type the following command :
ant run-client
- The client displays these lines:
running application client container.
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.- In the server log file, the following lines should be displayed, wrapped in logging information:
MESSAGE BEAN: Message received: This is message 1
MESSAGE BEAN: Message received: This is message 2
MESSAGE BEAN: Message received: This is message 3The received messages often appear in a different order from the order in which they were sent.
To undeploy the application after you finish running the client, use the following command:
To remove the generated files, use the following command:
Removing the Administered Objects
After you run the example, you can use the following Ant targets to delete the connection factory and queue: