Uh-oh, it looks like your Internet Explorer is out of date.

For a better shopping experience, please upgrade now.

Professional JMS

Professional JMS

by GIOTTA, Gopalan Suresh Raj, K. Scott Morrison, Silvano Maffeis, Meeraj Kunnumpurath
The JMS (Java Message Service) API (Application Program Interface) is a strategic technology for J2EE that provides a reliable, flexible service for the asynchronous exchange of critical business data and events throughout an enterprise - between computers rather than between users. By combining Java technology with enterprise messaging, the JMS API provides a new,


The JMS (Java Message Service) API (Application Program Interface) is a strategic technology for J2EE that provides a reliable, flexible service for the asynchronous exchange of critical business data and events throughout an enterprise - between computers rather than between users. By combining Java technology with enterprise messaging, the JMS API provides a new, powerful tool for solving enterprise computing problems. The JMS API adds to this a common API and provider framework that enables the development of portable, message based applications in the Java programming language. As a result enterprise messaging is now recognized as an essential tool for building enterprise applications.

Professional JMS takes a detailed look at JMS in the J2EE context and its function as an integration mechanism using XML as the message format. It provides developers with core JMS theory alongside practical case studies exemplifying real-world uses of JMS.

Product Details

Publication date:
Professional Ser.
Edition description:
Product dimensions:
(w) x (h) x 0.05(d)

Related Subjects

Read an Excerpt

Chapter 5: Publish/Subscribe Messaging

Publish/Subscribe (Pub/Sub) messaging in JMS is based on the concept of topics. The destination in the Pub/Sub domain model is the topic and message producers publish messages to a specified topic. Message consumers subscribe for messages from the topic and receive the messages from the topic when they become available.

Every topic can have multiple publishers (message producers) or subscribers (message consumers) and every message published is received by all the subscribers. Therefore, unlike the Point-to-Point (PTP) messaging model, multiple subscribers will receive the same message that was published to that topic. These messages can either be persistent or non-persistent. If they are non-persistent, they are not stored in a persistent storage (like a database). This means, they may be lost if the messaging server were to crash. However, persistent messages are not even considered sent before they are stored in the persistent store. The JMS specification dictates that the messaging system guarantees to deliver a persistent message at least once.

What we'll learn in this chapter:

  • We'll start off with a discussion on topics, including a look at Quality of Service in JMS applications.

  • Then we'll move on to see how to set up our software environment to start coding Pub/Sub applications.

  • After configuring our JMS server, we'll move on to developing a retail stock brokerage application, which provides ample opportunities for us to explore Pub/Sub messaging and transactions.

  • While we develop our stock brokerage example, we will also learn about the key JMS Pub/Sub features.


Messaging server administrators explicitly create topics so that publishers and subscribers can exchange messages. The message producers in this domain model are called publishers and message consumers are referred to as subscribers. Publishers send messages to the topics for subscribers to consume.

The publisher declares the Quality of Service (QoS) while sending the message by setting the delivery mode, the time-to-live, and the message priority. The publisher also specifies whether a reply is requested from the subscriber. The messaging server records these items in its internal buffers, acknowledges receipt of the message to the publisher, and sends off the message to all the registered subscribers of the topic.

Quality of Service (QoS)

JMS supports two types of message delivery:
  • Reliable message delivery

  • Guaranteed message delivery Each of these offers a different level of Quality of Service
The client application configures the type of message delivery when it publishes the message to its destination by specifying the delivery mode as a parameter.

Reliable Messaging

With this type of delivery mode (DeliveryMode.NON_PERSISTENT), the messaging server will deliver a message to its subscribing client as long as there are no application or network failures. Delivery would fail if some disruption were to occur. This is referred to as "At-Most-Once-Delivery". The default QoS level in JMS is reliable delivery.

Delivery of NON_PERSISTENT messages is attempted only once. If the client does not receive the message for any reason (either the server's internal buffer overflowed, or the client crashed, etc.), these NON_PERSISTENT messages are lost as shown in the figure below...

However, in the next scenario, assume that we have a message sent with NON_PERSISTENT delivery mode and a durable subscriber/receiver. In this situation, the scenario is as follows and is also represented diagrammatically in the figure below:

  • The message producer sends or publishes a message to the destination.

  • An acknowledgement for the message is sent back to the producer.

  • The messaging server realizes that there are durable subscribers that have not received the message and stores the message in its internal store.

  • A provider failure occurs – either the server's internal buffer overflowed, or the client crashed, etc.

  • Since the delivery mode for the message was NON_PERSISTENT, even though there are durable consumers, the message is lost.
Guaranteed Messaging

With this type of delivery mode (DeliveryMode.PERSISTENT), the messaging server will deliver a message even if there are application or network failures. The messaging server will store the message in its persistent store and then forward the message to its subscribing clients. After the client processes the message, it sends an acknowledgement to the messaging server and verifies the receipt of the message as shown below...

Meet the Author

Scott Grant is a Chief Architect with CascadeWorks, Inc., in San Francisco, California, and has over fifteen years of diverse development experience. An independent consultant for many years, he has been a successful founder of two start-up companies, where he has helped to build and shape the engineering teams and environments. A Sun Certified Java Developer, Scott has published numerous technical articles on Java programming subjects, and enjoys working with emerging Java standards and technologies.

Paul Giotta holds degrees in electrical engineering from both Rensselaer Polytechnic Institute and the Swiss Federal Institute of Technology. He began his career in the field of R&D for advanced military radar systems at AIL Systems in the US. He later moved to Switzerland and took up work in the development and implementation of financial analytics for the trading of fixed income derivatives at Credit Suisse. Paul ultimately entered the field of software engineering full time when he began work on the architecture and implementation of real-time distributed trading systems (based entirely on Publish/Subscribe messaging) at CS. He later moved on to the development of financial information systems at Olsen & Associates and also worked as an IT consultant for Cambridge Technology Partners. Paul is now chief architect for message servers at Softwired AG in Zurich.

Michael Kovacs is a Sun Certified Java 2 Programmer and has been working in Java for the past 3 years. He has worked on all aspects of web based software development from the browser to the database. He has recently joined BEA Systems in San Francisco, CA as a Senior Software Engineer working with the WebLogic team. Before joining BEA he relocated last spring from his home in Cleveland, OH to San Francisco to work for Carstation.com, which is where the basis for this book's work was inspired. In his previous programming life he was a C programmer who started out writing software for lottery systems. He has a Bachelor's degree in Electronic Engineering Technology from The University of Dayton. He can be reached at Michael_P_Kovacs@yahoo.com.

Meeraj Kunnumpurath works as a Senior Information Specialist with Electronic Data Systems, responsible for designing enterprise helpdesk and billing systems mainly using J2EE and XML.

Silvano Maffeis is CTO at Softwired, a leading vendor of Java messaging middleware for wireline and wireless networks. Silvano holds a Ph.D. in computer science and is the author of numerous publications about Java software development, middleware, and wireless communication.

K. Scott Morrison is the Director, Architecture and Technology, for Infowave Software. He is currently leading a number of teams confronting the challenges in opening corporate data stores to an ever-increasing variety of wireless devices. He is a frequent and very popular speaker on topics in XML, Java, and wireless system architectures. Prior to his joining Infowave, Scott was the Senior Architect in the e-business division at IBM's Pacific Development Centre. While at IBM, his focus was on building high-volume, high-transaction rate web systems for travel and transportation, as well as designing and auditing Internet security architectures for government and financial sector clients.

Scott began his career by spending eight years involved in medical imaging research at the University of British Columbia. Here, he worked on Positron Emission Tomography (PET) brain scanner design, produced educational CDROMs about Alzheimer's disease for physicians, and conducted original research into neurodegenerative disorders. He has been published extensively in leading journals in medicine and in physics. He has also been a consultant on a number of feature film and television productions. Scott's current research interests lie in enterprise XML messaging architectures, Java/XML integration, and development frameworks for wireless systems.

Gopalan Suresh Raj is a senior analyst, software architect, and developer with expertise in multi-tiered systems development, enterprise component architectures, and distributed object computing. He is also an active author, including contributions to Enterprise Java Computing-Applications and Architecture, Cambridge University Press, 1999, and The Awesome Power of JavaBeans, Manning Publications Co., 1998. His work has been published in numerous technical journals. Visit him at his popular website http://gsraj.tripod.com or mail him at gopalan@gmx.net.

Customer Reviews

Average Review:

Post to your social network


Most Helpful Customer Reviews

See all customer reviews