J2EE Messaging
Messaging, in the context of this chapter, is a means of communication between computer applications
or between components of a computer application. Messaging is an important part of enterprise
application programming. It enables loosely-coupled systems, more independence in application
components, integration of programs written in different languages, and more.
In this chapter we discuss support for messaging in the Java 2 Enterprise Edition (J2EE) Platform. The
Java Message Service (JMS) is an API for messaging. It specifies a standard set of interfaces for enabling
Java applications to exchange enterprise messages. The message-driven bean is a new type of Enterprise
JavaBean (EJB) that can receive JMS messages.
In this chapter we will learn to write applications that send and receive messages using JMS and see how to
write and use message-driven beans. To get the most out of this chapter you should be familiar with entity
and session Enterprise JavaBeans as well as XML. If you are not familiar with EJB you can read Chapter
19 or you can read only the JMS sections of this chapter and skip the section on message-driven beans. If
you are not familiar with XML then you can read Chapter 17, or just skip the section on JMS and XML.
This is the order in which we cover the topics in this chapter:
q
Messaging in general
q
Details of JMS
Messaging models
The Publish/Subscribe (Pub/Sub) messaging model
The Point-to-Point (PTP) messaging model
Parts of a JMS message
Transactions
JMS and XML