Java Message Service, 2nd Edition

Book description

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.

Publisher resources

View/Submit Errata

Table of contents

  1. Java Message Service
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Foreword
    4. Preface
      1. Who Should Read This Book?
      2. Organization
      3. Software and Versions
      4. Conventions Used in This Book
      5. Using Code Examples
      6. Safari® Books Online
      7. How to Contact Us
      8. Acknowledgments
      9. Acknowledgments from the First Edition
    5. 1. Messaging Basics
      1. The Advantages of Messaging
        1. Heterogeneous Integration
        2. Reduce System Bottlenecks
        3. Increase Scalability
        4. Increase End User Productivity
        5. Architecture Flexibility and Agility
      2. Enterprise Messaging
        1. Centralized Architectures
        2. Decentralized Architectures
        3. Hybrid Architectures
        4. Centralized Architecture As a Model
      3. Messaging Models
        1. Point-to-Point
        2. Publish-and-Subscribe
      4. JMS API
        1. Point-to-Point API
        2. Publish-and-Subscribe API
      5. Real-World Scenarios
        1. Service-Oriented Architecture
        2. Event-Driven Architecture
        3. Heterogeneous Platform Integration
        4. Enterprise Application Integration
        5. Business-to-Business
        6. Geographic Dispersion
        7. Information Broadcasting
        8. Building Dynamic Systems
      6. RPC Versus Asynchronous Messaging
        1. Tightly Coupled RPC
        2. Enterprise Messaging
    6. 2. Developing a Simple Example
      1. The Chat Application
        1. Getting Started with the Chat Example
        2. Examining the Source Code
          1. Bootstrapping the JMS client
          2. Obtaining a JNDI connection
          3. The TopicConnectionFactory
          4. The TopicConnection
          5. The TopicSession
          6. The Topic
          7. The TopicPublisher
          8. The TopicSubscriber
          9. The Message
        3. Sessions and Threading
    7. 3. Anatomy of a JMS Message
      1. Headers
        1. Automatically Assigned Headers
          1. JMSDestination
          2. JMSDeliveryMode
          3. JMSMessageID
          4. JMSTimestamp
          5. JMSExpiration
          6. JMSRedelivered
          7. JMSPriority
        2. Developer-Assigned Headers
          1. JMSReplyTo
          2. JMSCorrelationID
          3. JMSType
      2. Properties
        1. Application-Specific Properties
        2. JMS-Defined Properties
        3. Provider-Specific Properties
      3. Message Types
        1. Message
        2. TextMessage
        3. ObjectMessage
        4. BytesMessage
        5. StreamMessage
        6. MapMessage
        7. Read-Only Messages
        8. Client-Acknowledged Messages
        9. Interoperability and Portability of Messages
    8. 4. Point-to-Point Messaging
      1. Point-to-Point Overview
        1. When to Use Point-to-Point Messaging
      2. The QBorrower and QLender Application
        1. Configuring and Running the Application
        2. The QBorrower Class
          1. JMS Initialization
          2. Sending the message and receiving the response
        3. The QLender Class
      3. Message Correlation
      4. Dynamic Versus Administered Queues
      5. Load Balancing Using Multiple Receivers
      6. Examining a Queue
    9. 5. Publish-and-Subscribe Messaging
      1. Publish-and-Subscribe Overview
        1. When to Use Publish-and-Subscribe Messaging
      2. The TBorrower and TLender Application
        1. Configuring and Running the Application
        2. The TLender Class
          1. JMS initialization
          2. Publishing the message
        3. The TBorrower Class
      3. Durable Versus Nondurable Subscribers
      4. Dynamic Versus Administered Subscribers
      5. Unsubscribing Dynamic Durable Subscribers
      6. Temporary Topics
    10. 6. Message Filtering
      1. Message Selectors
        1. Identifiers
        2. Literals
        3. Comparison Operators
        4. Arithmetic Operators
      2. Declaring a Message Selector
      3. Message Selector Examples
        1. Managing Claims in an HMO
        2. Notification of Certain Bids on Inventory
        3. Priority Handling
        4. Stock Trade Order Auditing
      4. Not Delivered Semantics
      5. Design Considerations
    11. 7. Guaranteed Messaging and Transactions
      1. Guaranteed Messaging
        1. Message Autonomy
        2. Store-and-Forward Messaging
        3. Message Acknowledgments and Failure Conditions
      2. Message Acknowledgments
        1. AUTO_ACKNOWLEDGE
          1. The message producer’s perspective
          2. The message server’s perspective
          3. The message consumer’s perspective
          4. Message redelivery
          5. Point-to-point queues
        2. DUPS_OK_ACKNOWLEDGE
        3. CLIENT_ACKNOWLEDGE
          1. Grouping multiple messages
      3. Message Groups and Acknowledgment
        1. Handling Redelivery of Messages in an Application
        2. Message Groups Example
        3. Message Grouping and Multiple Receivers
      4. Transacted Messages
        1. Creating and Using a JMS Transaction
        2. Transacted Session Example
        3. Distributed Transactions
      5. Lost Connections
        1. The ExceptionListener Example
      6. Dead Message Queues
    12. 8. Java EE and Message-Driven Beans
      1. Java EE Overview
        1. Enterprise JavaBeans
      2. Enterprise JavaBeans 3.0 (EJB3) Overview
        1. Simplified Bean Development
        2. Dependency Injection
        3. Simplified Callback Methods
        4. Programmatic Defaults
        5. Interceptors
        6. Java Persistence API
      3. JMS Resources in Java EE
        1. The JNDI Environment Naming Context (ENC)
      4. Message-Driven Beans
        1. Concurrent Processing and Scalability
        2. Defining Message-Driven Beans
      5. Message-Driven Bean Use Cases
        1. Message Facade
        2. Transformation and Routing
    13. 9. Spring and JMS
      1. Spring Messaging Architecture
      2. JmsTemplate Overview
        1. Send Methods
        2. convertAndSend Methods
        3. receive and receiveSelected Methods
        4. receiveAndConvert Methods
      3. Connection Factories and JMS Destinations
        1. Using JNDI
        2. Using Native Classes
      4. Sending Messages
        1. Using the send Method
        2. Using the convertAndSend Method
        3. Using a Nondefault JMS Destination
      5. Receiving Messages Synchronously
      6. Message-Driven POJOs
        1. The Spring Message Listener Container
        2. MDP Option 1: Using the MessageListener Interface
        3. MDP Option 2: Using the SessionAwareMessageListener Interface
        4. MDP Option 3: Using the MessageListenerAdapter
          1. Default message handler method
          2. Custom message handler method
        5. Message Conversion Limitations
      7. The Spring JMS Namespace
        1. <jms:listener-container> Element Properties
        2. <jms:listener> Element Properties
    14. 10. Deployment Considerations
      1. Performance, Scalability, and Reliability
        1. Determining Message Throughput Requirements
        2. Testing the Real-World Scenario
          1. Testing with one client
          2. Send rate versus receive rate
          3. Determining hardware requirements
          4. Finding or building a test bed
          5. Long duration reliability
          6. Memory leaks
      2. To Multicast or Not to Multicast
        1. TCP/IP
        2. UDP
        3. IP Multicast
        4. Messaging Over IP Multicast
          1. Duplication, ordering, and reliability of messages
          2. Centralized and decentralized architectures
          3. Network routers and firewalls
          4. Some vendors support both centralized and decentralized architectures
        5. The Bottom Line
      3. Security
        1. Authentication
        2. Authorization
        3. Secure Communication
        4. Firewalls and HTTP Tunneling
      4. Connecting to the Outside World
      5. Bridging to Other Messaging Systems
    15. 11. Messaging Design Considerations
      1. Internal Versus External Destination
        1. Internal Destination Topology
        2. External Destination Topology
      2. Request/Reply Messaging Design
      3. Messaging Design Anti-Patterns
        1. Single-Purpose Queue
        2. Message Priority Overuse
        3. Message Header Misuse
    16. A. The Java Message Service API
      1. Message Interfaces
        1. BytesMessage
        2. MapMessage
        3. Message
        4. ObjectMessage
        5. StreamMessage
        6. TextMessage
      2. Common Facilities
        1. ConnectionMetaData
        2. DeliveryMode
        3. ExceptionListener
        4. JMSException
        5. MessageListener
      3. Common API
        1. Connection
        2. ConnectionFactory
        3. Destination
        4. MessageConsumer
        5. MessageProducer
        6. Session
      4. Point-to-Point API
        1. Queue
        2. QueueBrowser
        3. QueueConnection
        4. QueueConnectionFactory
        5. QueueReceiver
        6. QueueRequestor
        7. QueueSender
        8. QueueSession
        9. TemporaryQueue
      5. Publish-and-Subscribe API
        1. TemporaryTopic
        2. Topic
        3. TopicConnection
        4. TopicConnectionFactory
        5. TopicPublisher
        6. TopicRequestor
        7. TopicSession
        8. TopicSubscriber
    17. B. Message Headers
      1. JMSDestination
      2. JMSDeliveryMode
      3. JMSMessageID
      4. JMSTimestamp
      5. JMSExpiration
      6. JMSRedelivered
      7. JMSPriority
      8. JMSReplyTo
      9. JMSCorrelationID
      10. JMSType
    18. C. Message Properties
      1. Property Names
      2. Property Values
      3. Immutable Properties
      4. Property Value Conversion
      5. Nonexistent Properties
      6. Property Iteration
      7. JMS-Defined Properties
        1. Optional JMS-Defined Properties
        2. Group JMS-Defined Properties
      8. Provider-Specific Properties
    19. D. Installing and Configuring ActiveMQ
      1. Installing ActiveMQ
      2. Configuring ActiveMQ for JNDI
      3. Configuration For Chat Examples
      4. Configuration for P2P Examples
      5. Configuration for Pub/Sub Examples
      6. Configuration for Spring JMS Examples
    20. Index
    21. About the Authors
    22. Colophon
    23. SPECIAL OFFER: Upgrade this ebook with O’Reilly

Product information

  • Title: Java Message Service, 2nd Edition
  • Author(s): Mark Richards, Richard Monson-Haefel, David A Chappell
  • Release date: May 2009
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596555603