Java Reference
In-Depth Information
FIGURE 21-3. An Enterprise Bean Application: Client to Session Bean to Message-
Driven Bean
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 mes-
sages it receives.
Coding the Application Client: MyAppClient.java
The application client, clientsessionmdb-app-client/src/java/MyAp-
pClient.java , performs no JMS API operations and so is simpler than the client in
Chapter 11 , A Message-Driven Bean Example . ” The client uses dependency injection to
obtain the Publisher enterprise bean's business interface:
@EJB(name="PublisherRemote")
static private PublisherRemote publisher;
Search WWH ::




Custom Search