When Java™ was first introduced, most of the IT industry focused on its graphical user interface characteristics and the competitive advantage it offered in terms of distribution and platform independence. Today, the focus has broadened considerably: Java has been recognized as an excellent platform for creating enterprise solutions, specifically for developing distributed server-side applications. This shift has much to do with Java’s emerging role as a universal language for producing implementation-independent abstractions for common enterprise technologies. The JDBC™ API is the first and most familiar example. JDBC provides a vendor-independent Java interface for accessing SQL relational databases. This abstraction has been so successful that it’s difficult to find a relational database vendor that doesn’t support JDBC. Java abstractions for enterprise technologies have expanded considerably to include JNDI ( Java Naming and Directory Interface™) for abstracting directory services, JMX ( Java Management Extensions) for abstracting access to computer devices on a network, and JMS™ ( Java Message Service) for abstracting access to different Message-Oriented Middleware products.
JMS has quickly become a de facto industry standard. In its second version, most enterprise messaging vendors now support the JMS specification, making for a large selection of JMS providers to choose from.
The Java Message Service is a Java API implemented by enterprise messaging vendors to provide Java applications with a common and elegant programming model that is portable across messaging systems. Enterprise messaging systems are used to send notification of events and data between software applications. There are two common programming models supported by the JMS API: publish-and-subscribe and point-to-point. Each model provides benefits and either or both may be implemented by JMS providers.
JMS and enterprise messaging systems provide Java developers with an asynchronous messaging system that allows systems to interact without requiring them to be tightly coupled. Messages can be delivered to systems that are not currently running and processed when it’s convenient. The decoupled, asynchronous characteristics of enterprise messaging make JMS an extremely powerful and critical enterprise API. JMS is used by Java developers in Enterprise Application Integration, Business-to-Business (B2B) projects, and distributed computing in general.
As JMS quickly moves into the forefront as one of the most important J2EE technologies, understanding how JMS works and when to use it will become the hallmark of the most successful distributed computing professionals. Choosing to read this book to learn about JMS may be one of the smartest career moves you ever make.
This book explains and demonstrates the fundamentals of the the Java Message Service. This book provides a straightforward, no-nonsense explanation of the underlying technology, Java classes and interfaces, programming models, and various implemenations of the JMS specification.
Although this book focuses on the fundamentals, it’s no “dummy’s” book. While the JMS API is easy to learn, the API abstracts fairly complex enterprise technology. Before reading this book, you should be fluent with the Java language and have some practical experience developing business solutions. Experience with messaging systems is not required, but you must have a working knowledge of the Java language. If you are unfamiliar with the Java language, we recommend that you pick up a copy of Learning Java™ by Patrick Neimeyer and Jonathan Knudsen (O’Reilly). If you need a stronger background in distributed computing, we recommend Java™ Distributed Computing by Jim Farley (O’Reilly).
Here’s how the book is structured. The first chapter explains messaging systems, centralized and distributed architectures, and how and why JMS is important. Chapter 2 through Chapter 5 go into detail about developing JMS clients using the two messaging models, publish-and-subscribe and point-to-point. Chapter 6 and Chapter 7 should be considered “advanced topics,” covering deployment and administration of messaging systems. Chapter 8 is an overview of the Java™ 2, Enterprise Edition ( J2EE) with regard to JMS, including coverage of the new message-driven bean in Enterprise JavaBeans 2.0. Finally, Chapter 9 provides a summary of several JMS vendors and their products.
- Chapter 1
Defines enterprise messaging and common architectures used by messaging vendors. JMS is defined and explained, as are its two programming models, publish-and-subscribe and point-to-point.
- Chapter 2
Walks the reader through the development of a simple publish-and-subscribe JMS client.
- Chapter 3
Provides a detailed examination of the JMS message, the most important part of the JMS API.
- Chapter 4
Examines the publish-and-subscribe programming model through the development of a B2B JMS application.
- Chapter 5
Examines the point-to-point programming models through the enhancement of the B2B JMS application developed in Chapter 4.
- Chapter 6
Provides an in-depth explanation of advanced topics, including guaranteed messaging, transactions, acknowledgments, and failures.
- Chapter 7
Provides an in-depth examination of features and issues that should be considered when choosing vendors and deploying JMS applications.
- Chapter 8
Provides an overview of the Java™ 2, Enterprise Edition ( J2EE) with regard to JMS, and also includes coverage of the new JMS-based bean in Enterprise JavaBeans 2.0.
- Chapter 9
Provides a summary of several JMS vendors and their products, including: IBM’s MQSeries, Progress’ SonicMQ , Fiorano’s FioranoMQ , Softwired’s iBus, Sun’s JMQ , BEA’s WebLogic, and Exolab’s OpenJMS.
- Appendix A
Provides a quick reference to the classes and interfaces defined in the JMS package.
- Appendix B
Provides detailed information about message headers.
- Appendix C
Provides detailed information about message properties.
- Appendix D
Provides detailed information about message selectors.
This book covers the Java Message Service Version 1.0.2. It uses Java language features from the Java 1.1 platform. Because the focus of this book is to develop vendor-independent JMS clients and applications, we have stayed away from proprietary extensions and vendor-dependent idioms. Any JMS-compliant provider can be used with this book; you should be familiar with that provider’s specific installation, deployment, and runtime management procedures to work with the examples. To find out the details of installing and running JMS clients for a specific JMS provider, consult your JMS vendor’s documentation; these details aren’t covered by the JMS specification.
Examples developed in this book are available through the book’s catalog page at http://www.oreilly.com/catalog/javmesser/examples. The examples are organized by chapter. Special source code modified for specific vendors is also provided. These vendor-specific examples include a readme.txt file that points to documentation for downloading and installing the JMS provider, as well as specific instructions on setting up the provider for each example.
Italic is used for filenames, pathnames, hostnames, domain names, URLs, email addresses, and new terms where they are defined.
Constant
width
is used for code
examples and fragments, class, variable, and method names, Java
keywords used within the text, SQL commands, table names, column
names, and XML elements and tags.
Constant width bold
is used for emphasis in
some code examples.
Constant width italic
is used to indicate
text that is replaceable.
The term “JMS provider” is used to refer to a vendor that implements the JMS API to provide connectivity to their enterprise messaging service. The term “JMS client” refers to Java components or applications that use the JMS API and a JMS provider to send and receive messages. “JMS application” refers to any combination of JMS clients that work together to provide a software solution.
We have tested and verified the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!). Please let us know about any errors you find, as well as your suggestions for future editions, by writing to:
O’Reilly & Associates, Inc. |
101 Morris Street |
Sebastopol, CA 95472 |
(800) 998-9938 (in the United States or Canada) |
(707) 829-0515 (international or local) |
(707) 829-0104 (fax) |
We have a web page for this book, where we list errata, examples, or any additional information. You can access this page at:
http://www.oreilly.com/catalog/javmesser/ |
To comment or ask technical questions about this book, send email to:
bookquestions@oreilly.com |
For more information about our books, conferences, software, Resource Centers, and the O’Reilly Network, see our web site at:
http://www.oreilly.com |
Richard Monson-Haefel maintains a web site for the discussion of JMS and related distributed computing technologies (http://www.jMiddleware.com). jMiddleware.com provides news about this book as well as code tips, articles, and an extensive list of links to JMS resources.
David Chappell hosts a similar site, the SonicMQ Developers Exchange, which can be found at http://www.sonicmq.com/developers/.
While there are only two names on the cover of this book, the credit for its development and delivery is shared by many individuals. Michael Loukides, our editor, was pivotal to the success of this book. Without his experience, craft, and guidance, this book would not have been possible.
Many expert technical reviewers helped ensure that the material was technically accurate and true to the spirit of the Java Message Service. Of special note are Joseph Fialli, Anne Thomas Manes, and Chris Kasso of Sun Microsystems, Andrew Neumann and Giovanni Boschi of Progress, Thomas Haas of Softwired, Mikhail Rizkin of International Systems Group, and Jim Alateras of ExoLab. The contributions of these technical experts are critical to the technical and conceptual accuracy of this book. They brought a combination of industry and real-world experience to bear, and helped to make this the best book on JMS published today.
Thanks also to Mark Hapner of Sun Microsystems, the primary architect of Java 2, Enterprise Edition, who answered several of our most complex questions. Thanks to all the participants in the JMS-INTEREST mailing list hosted by Sun Microsystems for their interesting and informative postings.
Special appreciation goes to George St. Maurice of the SonicMQ tech writing team for his participation in organizing the examples for the O’Reilly web site.
Finally, the most sincere gratitude must be extended to our families. Richard Monson-Haefel thanks his wife, Hollie, for supporting and assisting him through yet another book. Her love makes everything possible. David Chappell thanks his wife, Wendy, and their children Dave, Amy, and Chris, for putting up with him during this endeavor.
David Chappell would also like to thank some of the members of the Progress SonicMQ team—Bill Wood, Andy Neumann, Giovanni Boschi, Christine Semeniuk, David Grigglestone, Bill Cullen, Perry Yin, Kathy Guo, Mitchell Horowitz, Greg O’Connor, Mike Theroux, Ron Rudis, Charlie Nuzzolo, Jeanne Abmayr, Oriana Merlo, George St. Maurice—for helping to ensure that the appropriate topics were addressed, and addressed accurately. And special thanks to George Chappell for helping him with “split infinitives.”
Get Java Message Service now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.