Java Reference
In-Depth Information
At this point, you have a basic understanding of messaging and are perhaps eager to see
some code. In the next section we'll introduce JMS and you'll write some producer code
that will be used by the ActionBazaar application to send the shipping messages.
The request-reply model
In the ActionBazaar example, you might want a receipt confirmation from Turtle once they
have the shipping request from the queue.
A third kind of model called request-reply comes in handy in these situations. In this mod-
el, you give the message receiver enough information so that they can “call you back.” This
is known as an overlay model because it's typically implemented on top of either PTP or
pub-sub models.
For example, in the PTP model, the sender specifies a queue to be used to send a reply to
(in JMS, this is called the reply-to queue), as well as a unique ID shared by both the out-
going and incoming messages (known as the correlation ID in JMS). The receiver receives
the message and sends a reply to the reply-to queue, copying the correlation ID. The sender
receives the message in the reply-to queue and determines which messages received a reply
by matching the correlation ID.
4.2. Introducing JMS
In this section we provide a brief overview of the JMS API by building a basic message
producer. JMS is a deceptively small API to a very powerful technology. The JMS API is
to messaging what the Java Database Connectivity (JDBC) API is to database access. JMS
provides a standard way of accessing MOM in Java and is therefore an alternative to using
product-specific APIs.
The easiest way to learn JMS is by looking at some code. We're going to explore JMS by
developing the ActionBazaar code that sends out the shipping request. As we described
in section 4.1.2 , when a user places an order, a shipping request is sent to a queue shared
between ActionBazaar and Turtle. The code in listing 4.1 sends the message out and
could be part of a method in a simple service invoked by the ActionBazaar application.
Search WWH ::




Custom Search