Coding the Application Client
Coding the Application Client
The Publisher enterprise bean in this example is the enterprise-application equivalent of a
wire-service news feed that categorizes news events into six news categories. The
message-driven bean could represent a newsroom, where the sports desk, for example, would
set up a subscription for all news events pertaining to sports.
The application client in the example injects the Publisher enterprise bean's remote home
interface and then calls the bean's business method. The enterprise bean creates 18 text
messages. For each message, it sets a String property randomly to one of six values
representing the news categories and then publishes the message to a topic. The message-driven
bean uses a message selector for the property to limit which of the published messages it
receives.
Writing the components of the application involves the following:
Coding the Application Client: MyAppClient.java
The application client program,
clientsessionmdb-app-client/src/java/MyAppClient.java
, performs no JMS API
Topic
Java EE Server
MDB Instance
EJB
Container
Application
Client
Session Bean
EJB
Container
Msg
Msg
Calls
Publishes
Delivers
FIGURE 321
A Java EE Application: Client to Session Bean to Message-Driven Bean
A Java EE Application That Uses the JMS API with a Session Bean
Chapter 32 · Java EE Examples Using the JMS API
965