126.96.36.199. Java Message Service (JMS): General enterprise messaging
JMS (JSR 914) is the Java Enterprise API for working with networked messaging services
and for writing message-oriented middleware (fondly referred to as MOM).
The word "message" means different things in different contexts. In the context of JMS, a
message is a chunk of data that is sent from one system to another in an asynchronous
manner. The data serves as a kind of event notification and is almost always intended to
be read by a computer program, not by a human. In a nondistributed system that uses the
standard Java event model, an Event object notifies the program that some important
event (such as the user clicking a mouse button) has occurred. In a distributed system, a
message serves a similar purpose: it notifies some part of the distributed system that an
interesting event has occurred. You can think of a networked message service as a
distributed event notification system.
JMS is also a good complement to the synchronous communication provided by RMI,
CORBA, and most web services built using JAX-RPC. When an RMI client, for example,
makes a remote method call on a server object, the client will block until the remote method
returns. JMS provides a way for you to communicate asynchronously with a remote
process: you can send your message and carry on with useful work while the message is
delivered and processed at the receiving end. If there's a response from the receiver(s), a
callback can be invoked on your end, and you can deal with it then.
Like JNDI and JDBC, JMS is an API layered on top of existing, vendor-specific messaging
services. In order to use JMS in your application, you need to obtain a JMS provider
implementation that supports your particular message server. Some J2EE application
servers bundle their own JMS providers that you can use as message servers; some of them
provide easy ways to bridge their application servers to other message services like IBM
MQSeries or SonicMQ; others provide neither and leave it to you to obtain and install a
Chapter 11 provides a tutorial on using JMS, and Appendix E documents the syntax for
JMS message selectors.