Java Reference
In-Depth Information
Chapter 11. A Message-Driven Bean Example
Message-driven beans can implement any messaging type. Most commonly, they imple-
ment the Java Message Service (JMS) technology. The example in this chapter uses JMS
technology, so you should be familiar with basic JMS concepts such as queues and mes-
sages. To learn about these concepts, see Chapter 20 , Java Message Service Concepts .”
This chapter describes the source code of a simple message-driven bean example. Before
proceeding, you should read the basic conceptual information in the section “What Is a
Message-Driven Bean?” in The Java EE 6 Tutorial: Basic Concepts as well as “ Using
Message-Driven Beans to Receive Messages Asynchronously on page 370 .
The following topics are addressed here:
• “ Overview of the simplemessage Example ” on page 227
• “ The simplemessage Application Client ” on page 228
• “ The Message-Driven Bean Class on page 229
• “ Running the simplemessage Example ” on page 231
Overview of the simplemessage Example
The simplemessage application has the following components:
SimpleMessageClient : An application client that sends several messages to a
queue
SimpleMessageBean : A message-driven bean that asynchronously receives and
processes the messages that are sent to the queue
Figure 11-1 illustrates the structure of this application. The application client sends mes-
sages to the queue, which was created administratively using the Administration Console.
The JMS provider (in this case, the GlassFish Server) delivers the messages to the instances
of the message-driven bean, which then processes the messages.
Search WWH ::




Custom Search