Java Message Service

Book description

This book is a thorough introduction to Java Message Service (JMS), the standard Java application program interface (API) from Sun Microsystems that supports the formal communication known as "messaging" between computers in a network. JMS provides a common interface to standard messaging protocols and to special messaging services in support of Java programs. The messages exchange crucial data between computers, rather than between users--information such as event notification and service requests. Messaging is often used to coordinate programs in dissimilar systems or written in different programming languages. Using the JMS interface, a programmer can invoke the messaging services of IBM's MQSeries, Progress Software's SonicMQ, and other popular messaging product vendors. In addition, JMS supports messages that contain serialized Java objects and messages that contain Extensible Markup Language (XML) pages. Messaging is a powerful new paradigm that makes it easier to uncouple different parts of an enterprise application. Messaging clients work by sending messages to a message server, which is responsible for delivering the messages to their destination. Message delivery is asynchronous, meaning that the client can continue working without waiting for the message to be delivered. The contents of the message can be anything from a simple text string to a serialized Java object or an XML document. Java Message Service shows how to build applications using the point-to-point and publish-and-subscribe models; how to use features like transactions and durable subscriptions to make an application reliable; and how to use messaging within Enterprise JavaBeans. It also introduces a new EJB type, the MessageDrivenBean, that is part of EJB 2.0, and discusses integration of messaging into J2EE.

Publisher resources

View/Submit Errata

Table of contents

  1. Java Message Service
  2. A Note Regarding Supplemental Files
  3. Dedication
  4. Preface
    1. What Is the Java Message Service?
    2. Who Should Read This Book?
    3. Organization
    4. Software and Versions
    5. Conventions
    6. Comments and Questions
    7. Acknowledgments
  5. 1. Understanding the Messaging Paradigm
    1. 1.1. Enterprise Messaging
      1. 1.1.1. Centralized Architectures
      2. 1.1.2. Decentralized Architectures
      3. 1.1.3. Hybrid Architectures
      4. 1.1.4. Centralized Architecture as a Model
    2. 1.2. The Java Message Service ( JMS)
      1. 1.2.1. JMS Messaging Models: Publish-and-Subscribe and Point-to-Point
        1. 1.2.1.1. Publish-and-subscribe
        2. 1.2.1.2. Point-to-point
    3. 1.3. Application Scenarios
      1. 1.3.1. Enterprise Application Integration
      2. 1.3.2. Business-to-Business
      3. 1.3.3. Geographic Dispersion
        1. 1.3.3.1. One-to-many, push-model applications
      4. 1.3.4. Building Dynamic Systems with Messaging and JMS
    4. 1.4. RPC Versus Asynchronous Messaging
      1. 1.4.1. Tightly Coupled RPC
      2. 1.4.2. Enterprise Messaging
  6. 2. Developing a Simple Example
    1. 2.1. The Chat Application
      1. 2.1.1. Getting Started with the Chat Example
      2. 2.1.2. Examining the Source Code
        1. 2.1.2.1. Bootstrapping the JMS client
        2. 2.1.2.2. Obtaining a JNDI connection
        3. 2.1.2.3. The TopicConnectionFactory
        4. 2.1.2.4. The TopicConnection
        5. 2.1.2.5. The TopicSession
        6. 2.1.2.6. The Topic
        7. 2.1.2.7. The TopicPublisher
        8. 2.1.2.8. The TopicSubscriber
        9. 2.1.2.9. The Message
      3. 2.1.3. Sessions and Threading
  7. 3. Anatomy of a JMS Message
    1. 3.1. Headers
      1. 3.1.1. Automatically Assigned Headers
        1. 3.1.1.1. JMSDestination
        2. 3.1.1.2. JMSDeliveryMode
        3. 3.1.1.3. JMSMessageID
        4. 3.1.1.4. JMSTimestamp
        5. 3.1.1.5. JMSExpiration
        6. 3.1.1.6. JMSRedelivered
        7. 3.1.1.7. JMSPriority
      2. 3.1.2. Developer-Assigned Headers
        1. 3.1.2.1. JMSReplyTo
        2. 3.1.2.2. JMSCorrelationID
        3. 3.1.2.3. JMSType
    2. 3.2. Properties
      1. 3.2.1. Application-Specific Properties
      2. 3.2.2. JMS-Defined Properties
      3. 3.2.3. Provider-Specific Properties
    3. 3.3. Message Selectors
      1. 3.3.1. Message Selector Examples
    4. 3.4. Message Types
      1. 3.4.1. Message
      2. 3.4.2. TextMessage
      3. 3.4.3. ObjectMessage
      4. 3.4.4. BytesMessage
      5. 3.4.5. StreamMessage
      6. 3.4.6. MapMessage
      7. 3.4.7. Read-Only Messages
      8. 3.4.8. Client-Acknowledged Messages
      9. 3.4.9. Interoperability and Portability of Messages
  8. 4. Publish-and-Subscribe Messaging
    1. 4.1. Getting Started with the B2B Application
      1. 4.1.1. Running the B2B Application
      2. 4.1.2. The B2B Source Code
        1. 4.1.2.1. The Wholesaler class
        2. 4.1.2.2. The Retailer class
    2. 4.2. Temporary Topics
    3. 4.3. Durable Subscriptions
    4. 4.4. Publishing the Message Persistently
      1. 4.4.1. Persistent Messages and Temporary Topics
    5. 4.5. JMSCorrelationID
    6. 4.6. Request and Reply
      1. 4.6.1. TopicSubscriber.receive( )
      2. 4.6.2. TopicRequestor
    7. 4.7. Unsubscribing
  9. 5. Point-to-Point Messaging
    1. 5.1. Point-to-Point and Publish-and-Subscribe
      1. 5.1.1. When to Use Point-to-Point Messaging
    2. 5.2. The QWholesaler and QRetailer
      1. 5.2.1. The QRetailer Class
      2. 5.2.2. The QWholesaler Class
    3. 5.3. Creating a Queue Dynamically
    4. 5.4. Load Balancing Using Multiple QueueSessions
    5. 5.5. Examining a Queue
      1. 5.5.1. The QWBrowser Source Code
  10. 6. Guaranteed Messaging, Transactions, Acknowledgments, and Failures
    1. 6.1. Guaranteed Messaging
      1. 6.1.1. Message Autonomy
      2. 6.1.2. Store-and-Forward Messaging
      3. 6.1.3. Message Acknowledgments and Failure Conditions
    2. 6.2. Message Acknowledgments
      1. 6.2.1. AUTO_ACKNOWLEDGE
        1. 6.2.1.1. The producer’s perspective
        2. 6.2.1.2. The server’s perspective
        3. 6.2.1.3. The consumer’s perspective
        4. 6.2.1.4. Message redelivery
        5. 6.2.1.5. Point-to-point queues
      2. 6.2.2. DUPS_OK_ACKNOWLEDGE
      3. 6.2.3. CLIENT_ACKNOWLEDGE
        1. 6.2.3.1. Grouping multiple messages
    3. 6.3. Message Groups and Acknowledgment
      1. 6.3.1. Handling Redelivery of Messages in an Application
      2. 6.3.2. Message Groups in QRetailer
        1. 6.3.2.1. Compensating transactions
    4. 6.4. Transacted Messages
      1. 6.4.1. Creating and Using a JMS Transaction
      2. 6.4.2. The Transacted Retailer Example
      3. 6.4.3. Distributed Transactions
    5. 6.5. Lost Connections
      1. 6.5.1. The Wholesaler Becomes an ExceptionListener
    6. 6.6. Dead Message Queues
  11. 7. Deployment Considerations
    1. 7.1. Performance, Scalability, and Reliability
      1. 7.1.1. Determining Message Throughput Requirements
      2. 7.1.2. Testing the Real-World Scenario
        1. 7.1.2.1. Testing with one client
        2. 7.1.2.2. Send rate versus receive rate
        3. 7.1.2.3. Determining hardware requirements
        4. 7.1.2.4. Finding or building a test bed
        5. 7.1.2.5. Long duration reliability
        6. 7.1.2.6. Memory leaks
    2. 7.2. To Multicast or Not to Multicast
      1. 7.2.1. TCP/IP
      2. 7.2.2. UDP
      3. 7.2.3. IP Multicast
      4. 7.2.4. Messaging Over IP Multicast
        1. 7.2.4.1. Duplication, ordering, and reliability of messages
        2. 7.2.4.2. Centralized and decentralized architectures
        3. 7.2.4.3. Network routers and firewalls
        4. 7.2.4.4. Some vendors support both centralized and decentralized architectures
      5. 7.2.5. The Bottom Line
    3. 7.3. Security
      1. 7.3.1. Authentication
      2. 7.3.2. Authorization
      3. 7.3.3. Secure Communication
      4. 7.3.4. Firewalls and HTTP Tunneling
    4. 7.4. Connecting to the Outside World
    5. 7.5. Bridging to Other Messaging Systems
  12. 8. J2EE, EJB, and JMS
    1. 8.1. J2EE Overview
      1. 8.1.1. Enterprise JavaBeans
      2. 8.1.2. Servlets
      3. 8.1.3. JavaServer Pages
    2. 8.2. J2EE: A United Platform
    3. 8.3. The JMS Resource in J2EE
    4. 8.4. The New Message-Driven Bean in EJB 2.0
  13. 9. JMS Providers
    1. 9.1. IBM: MQSeries
      1. 9.1.1. Version 5.1
      2. 9.1.2. Next Version
    2. 9.2. Progress: SonicMQ
      1. 9.2.1. Version 3.0
      2. 9.2.2. Next Version
    3. 9.3. Fiorano: FioranoMQ
      1. 9.3.1. FioranoMQ Multicast 4.5
      2. 9.3.2. FioranoMQ Enterprise 4.5
      3. 9.3.3. Next Version
    4. 9.4. Softwired: iBus
      1. 9.4.1. iBus//MessageBus 3.1
      2. 9.4.2. iBus//MessageServer 4.1
      3. 9.4.3. iBus//Mobile 1.0
      4. 9.4.4. Next Versions
    5. 9.5. Sun Microsystems: Java Message Queue
      1. 9.5.1. Version 1.1
      2. 9.5.2. Next Version
    6. 9.6. BEA: WebLogic Server
      1. 9.6.1. Version 5.1
      2. 9.6.2. Next Version
    7. 9.7. ExoLab: OpenJMS
      1. 9.7.1. Beta Version 0.4
      2. 9.7.2. Version 1.0
  14. A. The Java Message Service API
    1. A.1. Common Facilities
      1. A.1.1. BytesMessage
      2. A.1.2. Connection
      3. A.1.3. ConnectionFactory
      4. A.1.4. ConnectionMetaData
      5. A.1.5. DeliveryMode
      6. A.1.6. Destination
      7. A.1.7. ExceptionListener
      8. A.1.8. JMSException
      9. A.1.9. MapMessage
      10. A.1.10. Message
      11. A.1.11. MessageConsumer
      12. A.1.12. MessageListener
      13. A.1.13. MessageProducer
      14. A.1.14. ObjectMessage
      15. A.1.15. Session
      16. A.1.16. StreamMessage
      17. A.1.17. TextMessage
    2. A.2. Point-to-Point API
      1. A.2.1. Queue
      2. A.2.2. QueueBrowser
      3. A.2.3. QueueConnection
      4. A.2.4. QueueConnectionFactory
      5. A.2.5. QueueReceiver
      6. A.2.6. QueueSender
      7. A.2.7. QueueSession
      8. A.2.8. TemporaryQueue
    3. A.3. Publish-and-Subscribe API
      1. A.3.1. TemporaryTopic
      2. A.3.2. Topic
      3. A.3.3. TopicConnection
      4. A.3.4. TopicConnectionFactory
      5. A.3.5. TopicPublisher
      6. A.3.6. TopicSession
      7. A.3.7. TopicSubscriber
  15. B. Message Headers
    1. JMSDestination
    2. JMSDeliveryMode
    3. JMSMessageID
    4. JMSTimestamp
    5. JMSExpiration
    6. JMSRedelivered
    7. JMSPriority
    8. JMSReplyTo
    9. JMSCorrelationID
    10. JMSType
  16. C. Message Properties
    1. C.1. Property Names
    2. C.2. Property Values
    3. C.3. Read-Only Properties
    4. C.4. Property Value Conversion
    5. C.5. Nonexistent Properties
    6. C.6. Property Iteration
    7. C.7. JMS-Defined Properties
      1. C.7.1. Optional JMS-Defined Properties
      2. C.7.2. Group JMS-Defined Properties
    8. C.8. Provider-Specific Properties
  17. D. Message Selectors
    1. D.1. Identifiers
    2. D.2. Literals
    3. D.3. Comparison Operators
    4. D.4. Arithmetic Operators
    5. D.5. Declaring a Message Selector
    6. D.6. Not Delivered Semantics
  18. About the Authors
  19. Colophon
  20. Copyright

Product information

  • Title: Java Message Service
  • Author(s): David A Chappell, Richard Monson-Haefel
  • Release date: December 2000
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596000684