background image

Writing the Module Components

<< Overviewof the sendremote Example | Coding the Message-Driven Bean: >>
<< Overviewof the sendremote Example | Coding the Message-Driven Bean: >>

Writing the Module Components

Writing the Module Components for the sendremote
Example
Writing the components of the modules involves two tasks:
"Coding the Application Client: MultiAppServerClient.java" on page 987
"Coding the Message-Driven Bean: ReplyMsgBean.java" on page 988
Coding the Application Client: MultiAppServerClient.java
The application client class, multiclient/src/java/MultiAppServerClient.java, does the
following.
1. It injects resources for two connection factories and a topic.
2. For each connection factory, it creates a connection, a publisher session, a publisher, a
subscriber session, a subscriber, and a temporary topic for replies.
3. Each subscriber sets its message listener, ReplyListener, and starts the connection.
4. Each publisher publishes five messages and creates a list of the messages the listener should
expect.
Local
Java EE
Server
Remote
Java EE
Server
Application
Client
CF1
CF2
M1
RM1
M2
RM2
M1
RM1
M2
RM2
PTopic
Reply
Topic
Local MDB
Reply
Topic
PTopic
Remote MDB
FIGURE 32­4
A Java EE Application That Sends Messages to Two Servers
An Application Example That Deploys a Message-Driven Bean on Two Servers
Chapter 32 · Java EE Examples Using the JMS API
987