O'Reilly - Java Message Service
O'Reilly - Java Message Service
O'Reilly - Java Message Service
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Java</strong> <strong>Message</strong> <strong>Service</strong><br />
Messaging clients in JMS are called JMS clients, and the messaging system - the MOM - is<br />
called the JMS provider. A JMS application is a business system composed of many JMS<br />
clients and, generally, one JMS provider.<br />
In addition, a JMS client that produces a message is called a producer, while a JMS client<br />
that receives a message is called a consumer. A JMS client can be both a producer and a<br />
consumer. When we use the term consumer or producer, we mean a JMS client that<br />
consumes messages or produces messages, respectively. We use this terminology<br />
throughout the book.<br />
1.2.1.1 Publish-and-subscribe<br />
In pub/sub, one producer can send a message to many consumers through a virtual channel<br />
called a topic. Consumers, which receive messages, can choose to subscribe to a topic.<br />
Any messages addressed to a topic are delivered to all the topic's consumers. Every<br />
consumer receives a copy of each message. The pub/sub messaging model is by and large<br />
a push-based model, where messages are automatically broadcast to consumers without<br />
them having to request or poll the topic for new messages.<br />
In the pub/sub messaging model the producer sending the message is not dependent on the<br />
consumers receiving the message. Optionally, JMS clients that use pub/sub can establish<br />
durable subscriptions that allow consumers to disconnect and later reconnect and collect<br />
messages that were published while they were disconnected. The pub/sub JMS messaging<br />
model is discussed in greater detail in Chapter 2, and Chapter 4.<br />
1.2.1.2 Point-to-point<br />
The point-to-point messaging model allows JMS clients to send and receive messages both<br />
synchronously and asynchronously via virtual channels known as queues. The p2p<br />
messaging model has traditionally been a pull- or polling-based model, where messages<br />
are requested from the queue instead of being pushed to the client automatically. In JMS,<br />
however, an option exists that allows p2p clients to use a push model similar to pub/sub.<br />
A given queue may have multiple receivers, but only one receiver may consume each<br />
message. As shown in Figure 1.4, the JMS provider takes care of doling out the work,<br />
insuring that each message is consumed once and only once by the next available receiver<br />
in the group. The JMS specification does not dictate the rules for distributing messages<br />
among multiple receivers, although some JMS vendors have chosen to implement this as a<br />
load balancing capability. P2p also offers other features, such as a queue browser that<br />
allows a client to view the contents of a queue prior to consuming its messages - this<br />
browser concept is not available in the pub/sub model. The p2p messaging model is<br />
covered in more detail in Chapter 5.<br />
1.3 Application Scenarios<br />
Until now, our discussion of enterprise messaging has been somewhat abstract. This<br />
section attempts to give some real-world scenarios to provide you with a better idea of the<br />
types of problems that enterprise messaging systems can solve.<br />
11