background image

Consumes Messages from a Remote Server

<< Removing the Generated Files | Writing the Module Components >>
<< Removing the Generated Files | Writing the Module Components >>

Consumes Messages from a Remote Server

An Application Example That Consumes Messages from a
Remote Server
This section and the following section explain how to write, compile, package, deploy, and run a
pair of Java EE modules that run on two Java EE servers and that use the JMS API to interchange
messages with each other. It is a common practice to deploy different components of an
enterprise application on different systems within a company, and these examples illustrate on a
small scale how to do this for an application that uses the JMS API.
However, the two examples work in slightly different ways. In this first example, the
deployment information for a message-driven bean specifies the remote server from which it
will consume messages. In the next example, the same bean is deployed on two different servers,
so it is the client module that specifies the servers (one local, one remote) to which it is sending
messages.
This first example divides the example in
Chapter 23, "A Message-Driven Bean Example"
into
two modules (not applications): one containing the application client, and the other containing
the message-driven bean.
This section covers the following topics:
"Overview of the consumeremote Example Modules" on page 979
"Writing the Module Components for the consumeremote Example" on page 980
"Creating Resources for the consumeremote Example" on page 981
"Using Two Application Servers for the consumeremote Example" on page 981
"Building, Deploying, and Running the consumeremoteModules Using NetBeans IDE" on
page 982
"Building, Deploying, and Running the consumeremote Modules Using Ant" on page 983
You will find the source files for this section in
tut-install/javaeetutorial5/examples/jms/consumeremote/. Path names in this section are
relative to this directory.
Overview of the consumeremote Example Modules
Except for the fact that it is packaged as two separate modules, this example is very similar to the
one in
Chapter 23, "A Message-Driven Bean Example"
:
One module contains the application client, which runs on the remote system and sends
three messages to a queue.
The other module contains the message-driven bean, which is deployed on the local server
and consumes the messages from the queue on the remote server.
The basic steps of the modules are as follows.
An Application Example That Consumes Messages from a Remote Server
Chapter 32 · Java EE Examples Using the JMS API
979