12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 13 ■ SENDING MESSAGES<strong>Java</strong> Messaging ServiceAt a high level, the JMS architecture consists of the following components (see Figure 13-2):• A provider: JMS is only a specification, so it needs an underlying implementationto route messages, that is, the provider (aka a message broker). The providerhandles the buffering and delivery of messages by providing an implementation ofthe JMS API.• Clients: A client is any <strong>Java</strong> application or component that uses the JMS API toeither consume or produce a JMS message. Such a client is known as a JMS clientbecause it is a client of the underlying provider. “Client” is the generic term forproducer, sender, publisher, consumer, receiver, or subscriber.• Messages: These are the objects that clients send to or receive from the JMSprovider.• Administered objects: A message broker must provide administered objects to theclient (connection factories and destinations) either through JNDI lookups orinjection (as you’ll see later).Figure 13-2. JMS architectureThe messaging provider enables asynchronous communication by providing a destination wheremessages can be held until they can be delivered to a client. There are two different types of destination,each applying to a specific messaging model:• The point-to-point (P2P) model: In this model, the destination used to holdmessages is called a queue. When using point-to-point messaging, one client putsa message on a queue, and another client receives the message. Once the messageis acknowledged, the message provider removes the message from the queue.382

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!