Java Message Service: Creating Distributed Enterprise Applications

Java Message Service: Creating Distributed Enterprise Applications

NOOK Book(eBook)

$23.99 $31.99 Save 25% Current price is $23.99, Original price is $31.99. You Save 25%.
View All Available Formats & Editions

Available on Compatible NOOK Devices and the free NOOK Apps.
WANT A NOOK?  Explore Now

Overview

Java Message Service, Second Edition, is a thorough introduction to the standard API that supports "messaging" -- the software-to-software exchange of crucial data among network computers. You'll learn how JMS can help you solve many architectural challenges, such as integrating dissimilar systems and applications, increasing scalability, eliminating system bottlenecks, supporting concurrent processing, and promoting flexibility and agility.

Updated for JMS 1.1, this second edition also explains how this vendor-agnostic specification will help you write messaging-based applications using IBM's MQ, Progress Software's SonicMQ, ActiveMQ, and many other proprietary messaging services.

With Java Message Service, you will:

  • Build applications using point-to-point and publish-and-subscribe messaging models
  • Use features such as transactions and durable subscriptions to make an application reliable
  • Implement messaging within Enterprise JavaBeans (EJB) using message-driven beans
  • Use JMS with RESTful applications and with the Spring application framework

Messaging is a powerful paradigm that makes it easier to uncouple different parts of an enterprise application. Java Message Service, Second Edition, will quickly teach you how to use the key technology that lies behind it.

Product Details

ISBN-13: 9780596555603
Publisher: O'Reilly Media, Incorporated
Publication date: 05/19/2009
Sold by: Barnes & Noble
Format: NOOK Book
Pages: 330
File size: 3 MB

About the Author


Richard Monson-Haefel is a leading expert in Enterprise Java development. He is the architect of OpenEJB, an open source EJB server, and has consulted as an architect on Enterprise JavaBeans, CORBA, Java RMI, and other distributed computing projects over the past several years. Richard is also the author of O'Reilly's Enterprise JavaBeans.

Dave Chappell is vice president and SonicMQ chief technology evangelist at Progress Software Corp. Dave has over 18 years of industry experience building software tools and infrastructure for application developers, spanning all aspects of R&D, sales, marketing, and support services. Dave has also been published in Network World magazine and has presented technical topics at numerous speaking engagements including JavaOne and XMLOne.

As director of engineering for SonicMQ, Progress Software's award winning JMS Internet Commerce Messaging System, Dave oversaw the design and development of the fastest and most scalable, reliable, and robust implementation of JMS in the marketplace.

Dave has under his belt a broad cross-platform background in designing and developing Internet based middleware and distributed object systems across a wide range of technologies including C++, Java, DCOM, CORBA, and EJB. Dave's experience also includes development of client/server infrastructure, graphical user interfaces, language interpreters, and various utility libraries.

Table of Contents

Foreword xi

Preface xiii

1 Messaging Basics 1

The Advantages of Messaging 3

Heterogeneous Integration 3

Reduce System Bottlenecks 3

Increase Scalability 4

Increase End User Productivity 4

Architecture Flexibility and Agility 5

Enterprise Messaging 5

Centralized Architectures 7

Decentralized Architectures 7

Hybrid Architectures 8

Centralized Architecture As a Model 8

Messaging Models 9

Point-to-Point 10

Publish-and-Subscribe 10

JMS API 11

Point-to-Point API 13

Publish-and-Subscribe API 14

Real-World Scenarios 14

Service-Oriented Architecture 15

Event-Driven Architecture 16

Heterogeneous Platform Integration 16

Enterprise Application Integration 17

Business-to-Business 17

Geographic Dispersion 18

Information Broadcasting 18

Building Dynamic Systems 18

RPC Versus Asynchronous Messaging 21

Tightly Coupled RPC 21

Enterprise Messaging 23

2 Developing a Simple Example 25

The Chat Application 25

Getting Started with the Chat Example 28

Examining the Source Code 30

Sessions and Threading 39

3 Anatomy of a JMS Message 41

Headers 42

Automatically Assigned Headers 43

Developer-Assigned Headers 46

Properties 47

Application-Specific Properties 47

JMS-Defined Properties 49

Provider-Specific Properties 50

Message Types 50

Message 50

TextMessage 51

ObjectMessage 52

BytesMessage 53

StreamMessage 56

MapMessage 58

Read-Only Messages 60

Client-Acknowledged Messages 61

Interoperability and Portability of Messages 61

4 Point-to-Point Messaging 63

Point-to-Point Overview 63

When to Use Point-to-Point Messaging 66

The QBorrower and QLender Application 67

Configuring and Running the Application67

The QBorrower Class 69

The QLender Class 76

Message Correlation 81

Dynamic Versus Administered Queues 83

Load Balancing Using Multiple Receivers 84

Examining a Queue 85

5 Publish-and-Subscribe Messaging 87

Publish-and-Subscribe Overview 87

When to Use Publish-and-Subscribe Messaging 89

The TBorrower and TLender Application 90

Configuring and Running the Application 90

The TLender Class 92

The TBorrower Class 96

Durable Versus Nondurable Subscribers 100

Dynamic Versus Administered Subscribers 101

Unsubscribing Dynamic Durable Subscribers 104

Temporary Topics 104

6 Message Filtering 107

Message Selectors 109

Identifiers 110

Literals 111

Comparison Operators 111

Arithmetic Operators 113

Declaring a Message Selector 114

Message Selector Examples 116

Managing Claims in an HMO 116

Notification of Certain Bids on Inventory 116

Priority Handling 116

Stock Trade Order Auditing 117

Not Delivered Semantics 117

Design Considerations 118

7 Guaranteed Messaging and Transactions 125

Guaranteed Messaging 125

Message Autonomy 126

Store-and-Forward Messaging 126

Message Acknowledgments and Failure Conditions 126

Message Acknowledgments 127

AUTO_ACKNOWLEDGE 127

DUPS_OK_ACKNOWLEDGE 132

CLIENT_ACKNOWLEDGE 132

Message Groups and Acknowledgment 133

Handling Redelivery of Messages in an Application 134

Message Groups Example 134

Message Grouping and Multiple Receivers 143

Transacted Messages 145

Creating and Using a JMS Transaction 147

Transacted Session Example 147

Distributed Transactions 150

Lost Connections 151

The ExceptionListener Example 152

Dead Message Queues 153

8 Java EE and Message-Driven Beans 155

Java EE Overview 155

Enterprise JavaBeans 156

Enterprise JavaBeans 3.0 (EJB3) Overview 157

Simplified Bean Development 158

Dependency Injection 158

Simplified Callback Methods 159

Programmatic Defaults 159

Interceptors 160

Java Persistence API 162

JMS Resources in Java EE 162

The JNDI Environment Naming Context (ENC) 164

Message-Driven Beans 166

Concurrent Processing and Scalability 168

Defining Message-Driven Beans 168

Message-Driven Bean Use Cases 171

Message Facade 171

Transformation and Routing 173

9 Spring and JMS 177

Spring Messaging Architecture 177

JmsTemplate Overview 180

Send Methods 181

convertAndSend Methods 181

receive and receiveSelected Methods 182

receiveAndConvert Methods 183

Connection Factories and JMS Destinations 184

Using JNDI 184

Using Native Classes 187

Sending Messages 189

Using the send Method 190

Using the convertAndSend Method 191

Using a Nondefault JMS Destination 193

Receiving Messages Synchronously 195

Message-Driven POJOs 198

The Spring Message Listener Container 198

MDP Option 1: Using the MessageListener Interface 199

MDP Option 2: Using the SessionAwareMessageListener Interface 201

MDP Option 3: Using the MessageListenerAdapter 202

Message Conversion Limitations 207

The Spring JMS Namespace 208

<jms:listener-container> Element Properties 209

<jms:listener> Element Properties 211

10 Deployment Considerations 213

Performance, Scalability, and Reliability 213

Determining Message Throughput Requirements 213

Testing the Real-World Scenario 214

To Multicast or Not to Multicast 217

TCP/IP 218

UDP 218

IP Multicast 218

Messaging Over IP Multicast 219

The Bottom Line 221

Security 222

Authentication 222

Authorization 223

Secure Communication 224

Firewalls and HTTP Tunneling 224

Connecting to the Outside World 225

Bridging to Other Messaging Systems 227

11 Messaging Design Considerations 229

Internal Versus External Destination 229

Internal Destination Topology 230

External Destination Topology 231

Request/Reply Messaging Design 232

Messaging Design Anti-Patterns 236

Single-Purpose Queue 236

Message Priority Overuse 240

Message Header Misuse 240

A The Java Message Service API 245

B Message Headers 265

C Message Properties 277

D Installing and Configuring ActiveMQ 285

Index 291

Customer Reviews