You are previewing Java Message Service (JMS) for J2EE.
O'Reilly logo
Java Message Service (JMS) for J2EE

Book Description

The authoritative guide to JMS for enterprise developers. JMS API is gaining important popularity for Enterprise applications and there is no adequate documentation for JMS for the J2EE platform. This book covers not only the concepts, but also present simple examples to explain the concepts and real sample applications to show how to use those concepts and techniques.

J2EE is commonly used for enterprise applications. The Java(tm) Message Service (JMS) API has been developed by Sun working in close cooperation with the leading enterprise messaging vendors. Enterprise messaging is now recognized as an essential tool for building enterprise applications. By combining Java technology with enterprise messaging, the JMS API provides a new, powerful tool for solving enterprise computing problems. Enterprise messaging provides a reliable, flexible service for the asynchronous exchange of critical business data and events throughout an enterprise. 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.

Table of Contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. About the Technical Reviewers
  4. Acknowledgments
  5. Tell Us What You Think
  6. Introduction
    1. What You Need For the Book
    2. Who Should Read This Book
    3. Who This Book Is Not For
    4. Overview
    5. Conventions
      1. Tools to Write an XML File
  7. I. Introduction to Java Enterprise Edition
    1. 1. Java and Enterprise Applications
      1. Java 2 Standard and Enterprise Edition
      2. J2EE Architecture
      3. J2EE APIs
      4. Classification of J2EE Technologies
        1. Components
        2. Services
        3. Communication Services
      5. JNDI
        1. What Are Naming and Directory Services?
        2. What Is JNDI?
        3. JNDI Architecture
        4. JNDI Naming and Naming Packages
          1. Naming Package
        5. JNDI Directory Objects and Directory Package
          1. Directory Package
        6. JNDI URL and Composite Names
        7. Where Can You Use JNDI?
        8. Using JNDI
        9. Developing a Simple Java Application
      6. Summary
      7. Questions and Answers
    2. 2. Enterprise JavaBeans (EJB)
      1. History of EJB
        1. Distributed Programming and Applications
        2. Server-Side Programming
        3. Application Servers
        4. Enterprise JavaBeans (EJBs)
      2. JavaBeans and EJBs
      3. EJB Architecture
      4. EJB Container
      5. Using EJB
        1. Session Bean
        2. Entity Bean
        3. Classes and Interfaces
      6. Session Bean
        1. Stateful Session Bean
        2. Stateless Session Bean
        3. Client Access to a Session Bean
        4. Session Bean Methods
        5. What Do Session Bean Methods Do?
      7. Entity Beans
        1. Characteristics of an Entity Bean
        2. Types of Data Persistence
        3. Client Access to Entity Beans
        4. Parts of an Entity Bean
        5. What Do Entity Bean Methods Do?
      8. EJB and the Web
      9. EJB and JMS
      10. Summary
      11. Questions and Answers
    3. 3. Enterprise JavaBeans Examples
      1. Creating a Session Bean
      2. Creating an Entity Bean
      3. Presentation Tier on EJB
        1. Client Access to a Session Bean
        2. Client Access to an Entity Bean
      4. EJB and the Web
        1. Web Client Access to a Session Bean and an Entity Bean
        2. Web Client Access to an Entity Bean
      5. Summary
      6. Questions and Answers
  8. II. Introduction to a Messaging Service
    1. 4. Middleware and Message-Oriented Middleware
      1. History of MOM
        1. Transaction-Processing Monitors (TPMs)
        2. Remote Procedure Call (RPC)
        3. Object Request Brokers (ORBs)
        4. In-House Developed Middleware
        5. MOM
          1. Networking Features of MOM
          2. Types of MOM Architecture
            1. Centralized Architecture
            2. Decentralized Architecture
            3. Hybrid Architecture
      2. Types of Messaging Models
        1. Synchronization Type Models
          1. Synchronous Type Messaging
          2. Asynchronous Type Messaging
        2. Message-Sending Type Models
          1. Point-to-Point Type Messaging
          2. Publish-and-Subscribe Type Messaging
      3. Summary
      4. Questions and Answers
    2. 5. Concepts and Fundamentals of JMS Programming
      1. What Is a Messaging System or Service?
        1. Advantages and Disadvantages of a Messaging System
      2. What Is the JMS API?
        1. Point-to-Point and Publish-and-Subscribe Messaging
        2. The JMS API and the J2EE Platform
      3. Concepts of JMS Programming
        1. JMS Architecture
        2. Message Consumption
        3. Destinations
        4. Connection Factory
          1. The p2p Messaging Model for the Connection Factory
          2. The pub/sub Messaging Model for the Connection Factory
        5. Connections
          1. The p2p Messaging Model for a Connection
          2. The pub/sub Messaging Model for a Connection
        6. Sessions
          1. The p2p Messaging Model for a Session
          2. The pub/sub Messaging Model for Session
        7. Message Producer
          1. The p2p Messaging Model for a Message Producer
          2. The pub/sub Messaging Model for a Message Producer
        8. Message Consumer
          1. Synchronous Consuming for the p2p Messaging Model
          2. Synchronous Consuming for the pub/sub Messaging Model
          3. A Message Listener for Asynchronous Messaging
          4. Asynchronous Consuming for the p2p Messaging Model
          5. Asynchronous Consuming for the pub/sub Messaging Model
        9. Messages
          1. The Header Part of the Message Object
          2. The Properties Part of the Message Object
        10. Message Selectors
          1. The Body of the Message Object
            1. TextMessage Interface
            2. ObjectMessage Interface
            3. MapMessage Interface
            4. BytesMessage Interface
            5. StreamMessage Interface
      4. Summary
      5. Questions and Answers
    3. 6. JMS Programming Techniques with Examples
      1. Basic Steps for Writing a JMS Application
      2. A p2p Messaging Example
        1. A Sender-Client Application for the p2p Messaging Model
        2. A Receiver-Client Application for the p2p Messaging Model
        3. Running p2p Client Applications
      3. A pub/sub Messaging Example
        1. A Message Listener for a pub/sub Client Application
        2. A Publisher Client Application for the pub/sub Messaging Model
        3. A Subscriber Client Application for the pub/sub Messaging Model
      4. A pub/sub Messaging Example with a Message Selector
        1. A Message Listener for a pub/sub Client Application with a Message Selector
        2. A Publisher-Client Application for pub/sub with a Message Selector
        3. A Subscriber Client Application for pub/sub with a Message Selector
        4. Running pub/sub Client Applications with a Message Selector
      5. Summary
      6. Questions and Answers
  9. III. Java Message Service
    1. 7. JMS Reliability
      1. What Is Reliability?
      2. Basic Reliability Mechanisms
        1. Message Acknowledgment
          1. What Happens When the Session Terminates?
        2. Message Persistence
        3. Message Priority Level
        4. Message Expiration
        5. Temporary Destinations
          1. Why Do You Need Temporary Destinations?
      3. Advanced Reliability Mechanisms
        1. Using Local Transactions
          1. Specifying a Transaction
          2. A Combination of Processes in a Single Transaction
        2. Durable Subscription
          1. Comparing Durable and Nondurable Subscriptions
          2. Creating a Durable Subscription
          3. Writing a Durable Subscription Application
          4. Running a Nondurable Subscription
      4. Clustering for Reliability
      5. Summary
      6. Questions and Answers
    2. 8. JMS and XML
      1. What Is XML?
        1. HTML or XML?
        2. XML Syntax
        3. An XML Document Structure
      2. Processing an XML Document
      3. Validation of XML
        1. Schemas and DTD
        2. XML Namespace
      4. Processing Technologies
        1. DOM Technology
        2. SAX Technology
        3. Transformation Technologies
      5. A Sample Application Using the JAXP API in JMS
        1. Running the Sender and Receiver Applications
      6. Summary
      7. Questions and Answers
    3. 9. Message-Driven Beans
      1. What Is a Message-Driven Bean?
      2. Architecture of a Message-Driven Bean
        1. Life Cycle of a Message-Driven Bean
        2. The Message-Driven Bean Class
      3. Combining a Message-Driven Bean with Session and Entity Beans
      4. A Message-Driven Bean Example
        1. Deploying the Bean Class
        2. Running the Message-Driven Bean Application
      5. Summary
      6. Questions and Answers
    4. 10. JMS and the Web
      1. Architectures of a JMS Provider and a Web Client
        1. JMS and the Web in a Two-Tier Architecture
        2. JMS and the Web in a Three-Tier Architecture
      2. A Sample Application Using JMS through a Web Client
        1. A Web Client Application That Produces a Message to a JMS Destination
          1. Running a Web Client Sending a Message
        2. A Web Client Application That Consumes a Message from a JMS Destination
          1. Running a Web Client Receiving a Message
      3. Summary
      4. Questions and Answers
  10. IV. Java Message Service Applications
    1. 11. Developing Applications Using the JMS API
      1. The Design Layout of the “Ask Advance Payment” Application
        1. Source Code for the Applications
        2. What Does the Application Do?
        3. Running the Application
      2. Design Samples of JMS Applications
        1. The “Promoting” Application
        2. The “New Product” Application
      3. Summary
  11. V. Appendixes
    1. A. J2SE and J2EE Settings
      1. J2SE
        1. Downloading the J2SE SDK
        2. Setting Up J2SE
        3. Verifying the Installation of the J2SE SDK
        4. Configuring J2SE on Your System
        5. Configuring the PATH Variable for J2SE
          1. Configuring the CLASSPATH Variable for J2SE
      2. J2EE
        1. Downloading the J2EE SDK
        2. Setting Up J2EE
        3. Verifying the Installation of the J2EE SDK
        4. Configuring J2EE on Your System
          1. Configuring the PATH Variable for J2EE
          2. Configuring the CLASSPATH Variable for J2EE
      3. Forte for Java Community Edition
        1. Downloading the Forte for Java Community Edition
        2. Setting Up the Forte for Java Community Edition
        3. Testing the Forte for Java Community Edition
      4. Web Server for J2EE Applications
    2. B. Application Deployment Tool
      1. Starting the Deployment Tool
      2. Adding a New Application
      3. Adding an Enterprise Bean to the Application
      4. Deploying the Application
      5. Adding a Web Component to the Application
    3. C. Java Message Service (JMS) API Vendors
      1. Criteria to Choose an Appropriate JMS Vendor
      2. BEA Systems Inc. (WebLogic Server)
      3. IBM (MQSeries)
      4. iPlanet (JMQ or iMQ)
      5. Sun Microsystems (J2EE 1.3 Reference Server)
      6. TIBCO/Talarian (SmartSockets for JMS)
      7. Progress (SonicMQ)
      8. Fiorano (FioranoMQ)
      9. Softwired (iBus)
      10. ExoLab (OpenJMS)
      11. Macromedia (JRun)
    4. D. Overview of JMS Package Classes
      1. Class Hierarchy for the javax.jms Package
        1. class javax.jms.QueueRequester
        2. class javax.jms.TopicRequester
        3. class java.lang.Throwable
      2. Interface Hierarchy for the javax.jms Package
        1. The javax.jms.ConnectionFactory Interface
          1. The javax.jms.QueueConnectionFactory Interface
          2. The javax.jms.TopicConnectionFactory Interface
          3. The javax.jms.Connection Interface
          4. The javax.jms.QueueConnection Interface
          5. The javax.jms.TopicConnection Interface
          6. The javax.jms.ConnectionConsumer Interface
          7. The javax.jms.Destination Interface
          8. The javax.jms.Queue Interface
          9. The javax.jms.Topic Interface
        2. The javax.jms.Session Interface
          1. The javax.jms.QueueSession Interface
          2. The javax.jms.TopicSession Interface
          3. The javax.jms.XASession Interface
        3. The javax.jms.MessageProducer Interface
          1. The javax.jms.QueueSender Interface
          2. The javax.jms.TopicPublisher Interface
        4. The javax.jms.MessageConsumer Interface
          1. The javax.jms.QueueReceiver Interface
          2. The javax.jms.TopicSubscriber Interface
        5. The javax.jms.MessageListener Interface
        6. The javax.jms.Message Interface
          1. The javax.jms.BytesMessage Interface
          2. The javax.jms.MapMessage Interface
          3. The javax.jms.ObjectMessage Interface
          4. javax.jms.StreamMessage Interface
          5. The javax.jms.TextMessage Interface
        7. The javax.jms.QueueBrowser Interface