10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

An Application ExampleThat Consumes Messages from a Remote Server<br />

972<br />

1. <strong>The</strong> administrator starts two <strong>Java</strong> <strong>EE</strong> servers, one on each system.<br />

2. On the local server, the administrator deploys the message-driven bean module, which uses<br />

a connection factory that specifies the remote server where the client is deployed.<br />

3. On the remote server, the administrator places the client JAR file.<br />

4. <strong>The</strong> client module sends three messages to a queue.<br />

5. <strong>The</strong> message-driven bean consumes the messages.<br />

Figure 32–3 illustrates the structure of this application. You can see that it is almost identical to<br />

Figure 23–1 except that there are two <strong>Java</strong> <strong>EE</strong> servers. <strong>The</strong> queue used is the one on the remote<br />

server; the queue must also exist on the local server for resource injection to succeed.<br />

FIGURE 32–3 A <strong>Java</strong> <strong>EE</strong> Application That Consumes Messages from a Remote Server<br />

<strong>Java</strong> <strong>EE</strong> Server on Jupiter<br />

Application<br />

Client<br />

Sends<br />

Msg<br />

Queue<br />

Writing the Module Components for the<br />

consumeremote Example<br />

Writing the components of the modules involves<br />

■ Coding the application client<br />

■ Coding the message-driven bean<br />

Delivers<br />

Msg<br />

<strong>Java</strong> <strong>EE</strong> Server on Earth<br />

MDB Instance<br />

EJB<br />

Container<br />

<strong>The</strong> application client, jupiterclient/src/java/SimpleClient.java, is almost identical to<br />

the one in “<strong>The</strong> simplemessage Application Client” on page 674.<br />

Similarly, the message-driven bean, earthmdb/src/java/MessageBean.java, is almost<br />

identical to the one in “<strong>The</strong> Message-Driven Bean Class” on page 675.<br />

<strong>The</strong> only major difference is that the client and the bean are packaged in two separate modules.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!