Getting Started with Enterprise JavaBeans™

G

Message-Driven Beans

Tutorial Home Section Home Previous Section Next

Get

Get

The Java Message Service

     Enterprise messaging systems (EMS) comprise a product category often used in larger systems to provide assured delivery of messages between participating applications. These products are also known as message oriented middleware (MOM). As with many software products, the API for virtually every EMS/MOM is vendor proprietary. The JMS specification was written to unify these APIs for the Java developer, and includes both an API and a Service Provider Interface (SPI). The inclusion of the SPI means that vendors can write what amounts to a pluggable driver to implement the JMS specification. To the developer, this aspect of JMS means product independence and transparency, with only one standard API to learn.

     JMS supports two messaging methodologies (or domains): point-to-point (PTP) and publish and subscribe (pub/sub). PTP deals with queues, senders, and receivers. There may be many message senders to a queue, but, normally, only one type of receiver (since MDBs can be pooled, there may be several of a given type consuming messages from the queue). Once a message has been received, it is removed from the queue. Pub/sub deals with topics, publishers, and subscribers. There may be any number of publishers for a topic, and any number of subscribers to the topic (similar in concept to Java listeners). Subscribers are notified of a newly published message for a topic, and every subscriber gets a copy. JMS uses the notion of message producers for clients that generate and send or publish messages, and message consumers for clients that receive messages via queues or topics. Queues and topics are known as destinations.

     The basic steps in JMS programming are:

     All of the classes referenced above are in the javax.jms package. Although we will only use PTP in the example, these steps apply to programs for both message domains. For more information about JMS and JMS programming, see Resources.



Tutorial Home Section Home Previous Section Next