Skip to Main Content
Java Message Service, 2nd Edition
book

Java Message Service, 2nd Edition

by Mark Richards, Richard Monson-Haefel, David A Chappell
May 2009
Intermediate to advanced content levelIntermediate to advanced
330 pages
10h 34m
English
O'Reilly Media, Inc.
Content preview from Java Message Service, 2nd Edition

The QBorrower and QLender Application

To illustrate how point-to-point messaging works, we will use a simple decoupled request/reply example where a QBorrower class makes a simple mortgage loan request to a QLender class using point-to-point messaging. The QBorrower class sends the loan request to the QLender class using a LoanRequest queue, and based on certain business rules, the QLender class sends a response back to the QBorrower class using a LoanResponseQ queue indicating whether the loan request was approved or denied. Since the QBorrower is interested in finding out right away whether the loan was approved or not, once the loan request is sent, the QBorrower class will block and wait for a response from the QLender class before proceeding. This simple example models a typical messaging request/reply scenario.

Configuring and Running the Application

Before looking at the code, let’s look at how the application works. As with the Chat application, the QBorrower class and QLender class both include a main() method so they can be run as a standalone Java application. To keep the code vendor-agnostic, both classes need the connection factory name and queue names when starting the application. The QLender class is executed from the command line as follows:

java ch04.p2p.QLender ConnectionFactory RequestQueue

where ConnectionFactory is the name of the queue connection factory defined in your JMS provider and RequestQueue is the name of the queue that the QLender class should be listening ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reactive Systems in Java

Reactive Systems in Java

Clement Escoffier, Ken Finnigan
Java 8 in Action

Java 8 in Action

Mario Fusco, Alan Mycroft, Raoul-Gabriel Urma
The Well-Grounded Java Developer, Second Edition

The Well-Grounded Java Developer, Second Edition

Benjamin Evans, Martijn Verburg, Jason Clark

Publisher Resources

ISBN: 9780596802264Supplemental ContentErrata Page