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.

FIGURE 32–4 A <strong>Java</strong> <strong>EE</strong> Application That Sends Messages to Two Servers<br />

CF1<br />

Application<br />

Client<br />

CF2<br />

M1<br />

M2<br />

M1<br />

PTopic<br />

PTopic<br />

Writing the Module Components for the sendremote<br />

Example<br />

Writing the components of the modules involves two tasks:<br />

An Application ExampleThat Deploys a Message-Driven Bean onTwo Servers<br />

M2<br />

Local MDB<br />

RM1<br />

RM2<br />

Remote MDB<br />

RM1<br />

Reply<br />

Topic<br />

Reply<br />

Topic<br />

RM2<br />

Local<br />

<strong>Java</strong> <strong>EE</strong><br />

Server<br />

Remote<br />

<strong>Java</strong> <strong>EE</strong><br />

Server<br />

■ “Coding the Application Client: MultiAppServerClient.java” on page 979<br />

■ “Coding the Message-Driven Bean: ReplyMsgBean.java” on page 980<br />

Coding the Application Client: MultiAppServerClient.java<br />

<strong>The</strong> application client class, multiclient/src/java/MultiAppServerClient.java, does the<br />

following.<br />

1. It injects resources for two connection factories and a topic.<br />

2. For each connection factory, it creates a connection, a publisher session, a publisher, a<br />

subscriber session, a subscriber, and a temporary topic for replies.<br />

3. Each subscriber sets its message listener, ReplyListener, and starts the connection.<br />

4. Each publisher publishes five messages and creates a list of the messages the listener should<br />

expect.<br />

Chapter 32 • <strong>Java</strong> <strong>EE</strong> Examples Using the JMS API 979

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

Saved successfully!

Ooh no, something went wrong!