Running the simplemessage Example - The Java EE 6 Tutorial
2. Using the Tutorial Examples
3. Getting Started with Web Applications
4. JavaServer Faces Technology
7. Using JavaServer Faces Technology in Web Pages
8. Using Converters, Listeners, and Validators
9. Developing with JavaServer Faces Technology
10. JavaServer Faces Technology: Advanced Concepts
11. Using Ajax with JavaServer Faces Technology
12. Composite Components: Advanced Topics and Example
13. Creating Custom UI Components and Other Custom Objects
14. Configuring JavaServer Faces Applications
16. Uploading Files with Java Servlet Technology
17. Internationalizing and Localizing Web Applications
18. Introduction to Web Services
19. Building Web Services with JAX-WS
20. Building RESTful Web Services with JAX-RS
21. JAX-RS: Advanced Topics and Example
23. Getting Started with Enterprise Beans
24. Running the Enterprise Bean Examples
25. A Message-Driven Bean Example
Overview of the simplemessage Example
The simplemessage Application Client
26. Using the Embedded Enterprise Bean Container
27. Using Asynchronous Method Invocation in Session Beans
Part V Contexts and Dependency Injection for the Java EE Platform
28. Introduction to Contexts and Dependency Injection for the Java EE Platform
29. Running the Basic Contexts and Dependency Injection Examples
30. Contexts and Dependency Injection for the Java EE Platform: Advanced Topics
31. Running the Advanced Contexts and Dependency Injection Examples
32. Introduction to the Java Persistence API
33. Running the Persistence Examples
34. The Java Persistence Query Language
35. Using the Criteria API to Create Queries
36. Creating and Using String-Based Criteria Queries
37. Controlling Concurrent Access to Entity Data with Locking
38. Using a Second-Level Cache with Java Persistence API Applications
39. Introduction to Security in the Java EE Platform
40. Getting Started Securing Web Applications
41. Getting Started Securing Enterprise Applications
42. Java EE Security: Advanced Topics
Part VIII Java EE Supporting Technologies
43. Introduction to Java EE Supporting Technologies
45. Resources and Resource Adapters
46. The Resource Adapter Example
47. Java Message Service Concepts
48. Java Message Service Examples
49. Bean Validation: Advanced Topics
50. Using Java EE Interceptors
51. Duke's Bookstore Case Study Example
52. Duke's Tutoring Case Study Example
53. Duke's Forest Case Study Example
You can use either NetBeans IDE or Ant to build, package, deploy, and run the simplemessage example.
Administered Objects for the simplemessage Example
This example requires the following:
A JMS connection factory resource
A JMS destination resource
If you have run the simple JMS examples in Chapter 47, Java Message Service Concepts and have not deleted the resources, you already have these resources. Otherwise, the resources will be created automatically when you deploy the application.
For more information on creating JMS resources, see JMS Administered Objects for the Synchronous Receive Example.
To Run the simplemessage Application Using NetBeans IDE
- From the File menu, choose Open Project.
- In the Open Project dialog, navigate to:
tut-install/examples/ejb/
- Select the simplemessage folder.
- Select the Open as Main Project check box and the Open Required Projects check box.
- Click Open Project.
- In the Projects tab, right-click the simplemessage project and choose Build.
This task packages the application client and the message-driven bean, then creates a file named simplemessage.ear in the dist directory.
- Right-click the project and choose Run.
This command creates any needed resources, deploys the project, returns a JAR file named simplemessageClient.jar, and then executes it.
The output of the application client in the Output pane looks like this (preceded by application client container output):
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.
The output from the message-driven bean appears in the server log (domain-dir/logs/server.log), 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 3
The received messages may appear in a different order from the order in which they were sent.
To Run the simplemessage Application Using Ant
- In a terminal window, go to:
tut-install/examples/ejb/simplemessage/
- To compile the source files and package the application, use the following command:
ant
This target packages the application client and the message-driven bean, then creates a file named simplemessage.ear in the dist 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.
- To create any needed resources, deploy the application, and run the client using
Ant, use the following command:
ant run
Ignore the message that states that the application is deployed at a URL.
The output in the terminal window looks like this (preceded by application client container output):
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 appear, 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 3
The received messages may appear in a different order from the order in which they were sent.
Removing the Administered Objects for the simplemessage Example
After you run the example, you can use NetBeans IDE to remove the connection factory and queue, as described in To Delete JMS Resources Using NetBeans IDE. If you are not using NetBeans IDE, you can use the asadmin list-jms-resources command to list the resources, and the asadmin delete-jms-resource command to remove each one.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices


