Java Reference
In-Depth Information
Chapter 21. Java Message Service Examples
This chapter provides examples that show how to use the JMS API in various kinds of Java
EE applications. It covers the following topics:
• “
Writing Simple JMS Applications
” on page
378
• “
Writing Robust JMS Applications
” on page
406
• “
An Application That Uses the JMS API with an Entity
”
on page
421
page
429
on page
436
The examples are in the
tut-install
/examples/jms/
directory.
The steps to build and run each example are as follows:
1.
Use NetBeans IDE or Ant to compile and package the example.
2.
Use NetBeans IDE or Ant to deploy the example and create resources for it.
3.
Use NetBeans IDE, the
appclient
command, or Ant to run the client.
Each example has a
build.xml
file that refers to files in the
tut-install
/examples/
bp-project/
directory.
Each example has a
setup/glassfish-resources.xml
file that is used to create
resources for the example.
See
Chapter 11
,
“
A Message-Driven Bean Example
,
” for a simpler example of a Java EE
application that uses the JMS API.
Writing Simple JMS Applications
This section shows how to create, package, and run simple JMS clients that are packaged
as application clients and deployed to a Java EE server. The clients demonstrate the basic
tasks a JMS application must perform:
• Creating a connection and a session
• Creating message producers and consumers
• Sending and receiving messages