JavaTM Message Service Tutorial By Kim Haase
Tutorial Homepage | TOC | Prev | Next | Index Revised: March 20, 2002

Contents

1  Overview

1.1  What Is Messaging?
1.2  What Is the JMS API?
1.3  When Can You Use the JMS API?
1.4  How Does the JMS API Work with the J2EETM Platform?

2  Basic JMS API Concepts

2.1  JMS API Architecture
2.2  Messaging Domains
2.2.1  Point-to-Point Messaging Domain
2.2.2  Publish/Subscribe Messaging Domain
2.3  Message Consumption

3  The JMS API Programming Model

3.1  Administered Objects
3.1.1  Connection Factories
3.1.2  Destinations
3.2  Connections
3.3  Sessions
3.4  Message Producers
3.5  Message Consumers
3.5.1  Message Listeners
3.5.2  Message Selectors
3.6  Messages
3.6.1  Message Headers
3.6.2  Message Properties
3.6.3  Message Bodies
3.7  Exception Handling

4  Writing Simple JMS Client Applications

4.1  Setting Your Environment for Running Applications
4.2  A Simple Point-to-Point Example
4.2.1  Writing the PTP Client Programs
4.2.2  Compiling the PTP Clients
4.2.3  Starting the JMS Provider
4.2.4  Creating the JMS Administered Objects
4.2.5  Running the PTP Clients
4.2.6  Deleting the Queue
4.3  A Simple Publish/Subscribe Example
4.3.1  Writing the Pub/Sub Client Programs
4.3.2  Compiling the Pub/Sub Clients
4.3.3  Starting the JMS Provider
4.3.4  Creating the JMS Administered Objects
4.3.5  Running the Pub/Sub Clients
4.3.6  Deleting the Topic and Stopping the Server
4.4  Running JMS Client Programs on Multiple Systems
4.4.1  Communicating Between Two J2EE Servers
4.4.2  Communicating Between a J2EE Server and a System Not Running a J2EE Server

5  Creating Robust JMS Applications

5.1  Using Basic Reliability Mechanisms
5.1.1  Controlling Message Acknowledgment
5.1.2  Specifying Message Persistence
5.1.3  Setting Message Priority Levels
5.1.4  Allowing Messages to Expire
5.1.5  Creating Temporary Destinations
5.2  Using Advanced Reliability Mechanisms
5.2.1  Creating Durable Subscriptions
5.2.2  Using JMS API Local Transactions

6  Using the JMS API in a J2EE Application

6.1  Using Enterprise Beans to Produce and to Synchronously Receive Messages
6.1.1  Administered Objects
6.1.2  Resource Management
6.1.3  Transactions
6.2  Using Message-Driven Beans
6.3  Managing Distributed Transactions
6.4  Using the JMS API with Application Clients and Web Components

7  A Simple J2EE Application that Uses the JMS API

7.1  Writing and Compiling the Application Components
7.1.1  Coding the Application Client: SimpleClient.java
7.1.2  Coding the Message-Driven Bean: MessageBean.java
7.1.3  Compiling the Source Files
7.2  Creating and Packaging the Application
7.2.1  Starting the J2EE Server and the Deploytool
7.2.2  Creating a Queue
7.2.3  Creating the J2EE Application
7.2.4  Packaging the Application Client
7.2.5  Packaging the Message-Driven Bean
7.2.6  Checking the JNDI Names
7.3  Deploying and Running the Application
7.3.1  Looking at the Deployment Descriptor
7.3.2  Adding the Server
7.3.3  Deploying the Application
7.3.4  Running the Client
7.3.5  Undeploying the Application
7.3.6  Removing the Application and Stopping the Server

8  A J2EE Application that Uses the JMS API with a Session Bean

8.1  Writing and Compiling the Application Components
8.1.1  Coding the Application Client: MyAppClient.java
8.1.2  Coding the Publisher Session Bean
8.1.3  Coding the Message-Driven Bean: MessageBean.java
8.1.4  Compiling the Source Files
8.2  Creating and Packaging the Application
8.2.1  Starting the J2EE Server and the Deploytool
8.2.2  Creating a Topic
8.2.3  Creating a Connection Factory
8.2.4  Creating the J2EE Application
8.2.5  Packaging the Application Client
8.2.6  Packaging the Session Bean
8.2.7  Packaging the Message-Driven Bean
8.2.8  Specifying the JNDI Names
8.3  Deploying and Running the Application
8.3.1  Adding the Server
8.3.2  Deploying the Application
8.3.3  Running the Client
8.3.4  Undeploying the Application
8.3.5  Removing the Application and Stopping the Server

9  A J2EE Application that Uses the JMS API with an Entity Bean

9.1  Overview of the Human Resources Application
9.2  Writing and Compiling the Application Components
9.2.1  Coding the Application Client: HumanResourceClient.java
9.2.2  Coding the Message-Driven Beans
9.2.3  Coding the Entity Bean
9.2.4  Compiling the Source Files
9.3  Creating and Packaging the Application
9.3.1  Starting the J2EE Server and the Deploytool
9.3.2  Creating a Queue
9.3.3  Starting the Cloudscape Database Server
9.3.4  Creating the J2EE Application
9.3.5  Packaging the Application Client
9.3.6  Packaging the Equipment Message-Driven Bean
9.3.7  Packaging the Office Message-Driven Bean
9.3.8  Packaging the Schedule Message-Driven Bean
9.3.9  Packaging the Entity Bean
9.3.10  Specifying the Entity Bean Deployment Settings
9.3.11  Specifying the JNDI Names
9.4  Deploying and Running the Application
9.4.1  Adding the Server
9.4.2  Deploying the Application
9.4.3  Running the Client
9.4.4  Undeploying the Application
9.4.5  Removing the Application and Stopping the Server

10  An Application Example that Uses Two J2EE Servers

10.1  Overview of the Applications
10.2  Writing and Compiling the Application Components
10.2.1  Coding the Application Client: MultiAppServerRequester.java
10.2.2  Coding the Message-Driven Bean: ReplyMsgBean.java
10.2.3  Compiling the Source Files
10.3  Creating and Packaging the Application
10.3.1  Starting the J2EE Servers and the Deploytool
10.3.2  Creating a Connection Factory
10.3.3  Creating the First J2EE Application
10.3.4  Packaging the Application Client
10.3.5  Creating the Second J2EE Application
10.3.6  Packaging the Message-Driven Bean
10.3.7  Checking the JNDI Names
10.4  Deploying and Running the Applications
10.4.1  Adding the Server
10.4.2  Deploying the Applications
10.4.3  Running the Client
10.4.4  Undeploying the Applications
10.4.5  Removing the Applications and Stopping the Servers
10.5  Accessing a J2EE Application from a Remote System that Is Not Running a J2EE Server
10.5.1  Accessing a J2EE Application from a Standalone Client
10.5.2  Using runclient to Access a Remote Application Client

Appendix A   JMS Client Examples

A.1  Durable Subscriptions
A.2  Transactions
A.3  Acknowledgment Modes
A.4  Utility Class


TOC | Prev | Next | Index

This Tutorial contains information on the 1.3.1 version of the Java 2 Platform, Enterprise Edition.

Copyright © 2002 Sun Microsystems, Inc. All rights reserved.