The Java Messaging Service is a messaging oriented middleware API designed by Sun. The client makes use of these APIs, allowing portability with any JMS implementation. JMS allows clients to be de-coupled from one another. The clients do not communicate with each other directly, but rather by sending messages to each other through middleware. Each client in a JMS environment connects to a messaging server. The messaging server facilitates the flow of messages among all clients. The messaging server guarantees that all messages arrive at the appropriate destinations. The messaging server also guarantees quality of services as transactions (local or XA), persistence, durability, and others.
Clients send messages to or receive messages from Topics or Queues (see Figure 1–1 and Figure 1–2). The difference between a Topic and a Queue is that all subscribers to a Topic receive the same message when the message is published and only one subscriber to a Queue receives a message when the message is sent.
Figure 1–1 shows multiple subscribers receiving the same messages when the publisher publishes the message to a Topic. This is the pubsub (publish-subscribe) model.
The Point-to-Point model (Figure 1–2), on the other hand, allows for only one receiver to get the message when a sender sends a message to a Queue.