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

Chapter 5. Publish-and-Subscribe Messaging

This chapter focuses on the publish-and-subscribe (pub/sub) messaging model. This messaging model is used when you need to broadcast an event or message to many message consumers. Unlike the point-to-point messaging model discussed in Chapter 4, all message consumers (called subscribers) listening on the topic will receive the message.

In this chapter, we will describe the publish-and-subscribe model through the use of a typical broadcast messaging scenario where a mortgage lender publishes its latest mortgage rates for a 30-year fixed mortgage to various borrowers in the hope of attracting one of the borrowers to apply for a mortgage loan. The TLender class will publish a new mortgage rate through a topic, and the TBorrower class will subscribe to the topic and make a decision on whether or not it is a good rate.

We have mentioned several new terms already in this chapter: topic, subscriber, and publish. Before moving on to the code example, we will first describe the main characteristics and nomenclature of the publish-and-subscribe model and discuss some of the typical use cases for this model.

Publish-and-Subscribe Overview

The publish-and-subscribe model is more commonly referred to as the pub/sub model. In this model, the message producer is called a publisher and the message consumer a subscriber. Messages are published to a topic as opposed to being sent to a queue, as in the point-to-point model. The most important characteristics ...

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