Movatterモバイル変換


[0]ホーム

URL:


Document Information

Preface

Part I Introduction

1.  Overview

2.  Using the Tutorial Examples

Part II The Web Tier

3.  Getting Started with Web Applications

4.  Java Servlet Technology

5.  JavaServer Pages Technology

6.  JavaServer Pages Documents

7.  JavaServer Pages Standard Tag Library

8.  Custom Tags in JSP Pages

9.  Scripting in JSP Pages

10.  JavaServer Faces Technology

11.  Using JavaServer Faces Technology in JSP Pages

12.  Developing with JavaServer Faces Technology

13.  Creating Custom UI Components

14.  Configuring JavaServer Faces Applications

15.  Internationalizing and Localizing Web Applications

Part III Web Services

16.  Building Web Services with JAX-WS

17.  Binding between XML Schema and Java Classes

18.  Streaming API for XML

19.  SOAP with Attachments API for Java

Part IV Enterprise Beans

20.  Enterprise Beans

21.  Getting Started with Enterprise Beans

22.  Session Bean Examples

23.  A Message-Driven Bean Example

Part V Persistence

24.  Introduction to the Java Persistence API

25.  Persistence in the Web Tier

26.  Persistence in the EJB Tier

27.  The Java Persistence Query Language

Part VI Services

28.  Introduction to Security in the Java EE Platform

29.  Securing Java EE Applications

30.  Securing Web Applications

31.  The Java Message Service API

Overview of the JMS API

What Is Messaging?

What Is the JMS API?

When Can You Use the JMS API?

How Does the JMS API Work with the Java EE Platform?

Basic JMS API Concepts

JMS API Architecture

Messaging Domains

Point-to-Point Messaging Domain

Publish/Subscribe Messaging Domain

Programming with the Common Interfaces

Message Consumption

The JMS API Programming Model

JMS Administered Objects

JMS Connection Factories

JMS Destinations

JMS Connections

JMS Sessions

JMS Message Producers

JMS Message Consumers

JMS Message Listeners

JMS Message Selectors

JMS Messages

Message Headers

Message Properties

Message Bodies

JMS Queue Browsers

JMS Exception Handling

Writing Simple JMS Client Applications

A Simple Example of Synchronous Message Receives

Writing the Client Programs for the Synchronous Receive Example

Starting the JMS Provider

Creating JMS Administered Objects for the Synchronous Receive Example

Compiling and Packaging the Clients for the Synchronous Receive Example

Running the Clients for the Synchronous Receive Example

A Simple Example of Asynchronous Message Consumption

Writing the Client Programs for the Asynchronous Receive Example

Compiling and Packaging theAsynchConsumer Client

Running the Clients for the Asynchronous Receive Example

A Simple Example of Browsing Messages in a Queue

Writing the Client Program for the Queue Browser Example

Compiling and Packaging theMessageBrowser Client

Running the Clients for the Queue Browser Example

Running JMS Client Programs on Multiple Systems

Creating Administered Objects for Multiple Systems

Editing, Recompiling, Repackaging, and Running the Programs

Deleting the Connection Factory and Stopping the Server

Creating Robust JMS Applications

Using Basic Reliability Mechanisms

Controlling Message Acknowledgment

Specifying Message Persistence

Setting Message Priority Levels

Allowing Messages to Expire

Creating Temporary Destinations

Using Advanced Reliability Mechanisms

Creating Durable Subscriptions

Using JMS API Local Transactions

Using the JMS API in a Java EE Application

Using@Resource Annotations in Java EE Components

Using Session Beans to Produce and to Synchronously Receive Messages

Resource Management

Transactions

Using Message-Driven Beans to Receive Messages Asynchronously

Managing Distributed Transactions

Using the JMS API with Application Clients and Web Components

Further Information about JMS

32.  Java EE Examples Using the JMS API

33.  Transactions

34.  Resource Connections

35.  Connector Architecture

Part VII Case Studies

36.  The Coffee Break Application

37.  The Duke's Bank Application

Part VIII Appendixes

A.  Java Encoding Schemes

B.  About the Authors

Index

 

The Java EE 5 Tutorial

Java Coffee Cup logo
PreviousContentsNext

Overview of the JMS API

This overview of the JMS API answers the following questions.

What Is Messaging?

Messaging is a method of communication between software components or applications. A messagingsystem is a peer-to-peer facility: A messaging client can send messages to, andreceive messages from, any other client. Each client connects to a messaging agentthat provides facilities for creating, sending, receiving, and reading messages.

Messaging enables distributed communication that isloosely coupled. A component sends a messageto a destination, and the recipient can retrieve the message from the destination.However, the sender and the receiver do not have to be available atthe same time in order to communicate. In fact, the sender does notneed to know anything about the receiver; nor does the receiver need toknow anything about the sender. The sender and the receiver need to knowonly which message format and which destination to use. In this respect, messagingdiffers from tightly coupled technologies, such as Remote Method Invocation (RMI), which requirean application to know a remote application’s methods.

Messaging also differs from electronic mail (email), which is a method of communicationbetween people or between software applications and people. Messaging is used for communicationbetween software applications or software components.

What Is the JMS API?

The Java Message Service is a Java API that allows applications tocreate, send, receive, and read messages. Designed by Sun and several partner companies, theJMS API defines a common set of interfaces and associated semantics that allowprograms written in the Java programming language to communicate with other messaging implementations.

The JMS API minimizes the set of concepts a programmer must learnin order to use messaging products but provides enough features to support sophisticated messagingapplications. It also strives to maximize the portability of JMS applications across JMSproviders in the same messaging domain.

The JMS API enables communication that is not only loosely coupled but also

  • Asynchronous: A JMS provider can deliver messages to a client as they arrive; a client does not have to request messages in order to receive them.

  • Reliable: The JMS API can ensure that a message is delivered once and only once. Lower levels of reliability are available for applications that can afford to miss messages or to receive duplicate messages.

The JMS specification was first published in August 1998. The latest version isVersion 1.1, which was released in April 2002. You can download a copyof the specification from the JMS web site:http://www.oracle.com/technetwork/java/index-jsp-142945.html.

When Can You Use the JMS API?

An enterprise application provider is likely to choose a messaging API over atightly coupled API, such as remote procedure call (RPC), under the following circumstances.

  • The provider wants the components not to depend on information about other components’ interfaces, so that components can be easily replaced.

  • The provider wants the application to run whether or not all components are up and running simultaneously.

  • The application business model allows a component to send information to another and to continue to operate without receiving an immediate response.

For example, components of an enterprise application for an automobile manufacturer can usethe JMS API in situations like these:

  • The inventory component can send a message to the factory component when the inventory level for a product goes below a certain level so that the factory can make more cars.

  • The factory component can send a message to the parts components so that the factory can assemble the parts it needs.

  • The parts components in turn can send messages to their own inventory and order components to update their inventories and to order new parts from suppliers.

  • Both the factory and the parts components can send messages to the accounting component to update their budget numbers.

  • The business can publish updated catalog items to its sales force.

Using messaging for these tasks allows the various components to interact with oneanother efficiently, without tying up network or other resources.Figure 31-1 illustrates howthis simple example might work.

Figure 31-1 Messaging in an Enterprise Application

Diagram showing messaging between various departments in an enterprise

Manufacturing is only one example of how an enterprise can use theJMS API. Retail applications, financial services applications, health services applications, and many others canmake use of messaging.

How Does the JMS API Work with the Java EE Platform?

When the JMS API was introduced in 1998, its most important purpose wasto allow Java applications to access existing messaging-oriented middleware (MOM) systems, such asMQSeries from IBM. Since that time, many vendors have adopted and implemented theJMS API, so a JMS product can now provide a complete messaging capabilityfor an enterprise.

Beginning with the 1.3 release of the Java EE platform, the JMSAPI has been an integral part of the platform, and application developers can usemessaging with Java EE components.

The JMS API in the Java EE platform has the following features.

  • Application clients, Enterprise JavaBeans (EJB) components, and web components can send or synchronously receive a JMS message. Application clients can in addition receive JMS messages asynchronously. (Applets, however, are not required to support the JMS API.)

  • Message-driven beans, which are a kind of enterprise bean, enable the asynchronous consumption of messages. A JMS provider can optionally implement concurrent processing of messages by message-driven beans.

  • Message send and receive operations can participate in distributed transactions, which allow JMS operations and database accesses to take place within a single transaction.

The JMS API enhances the Java EE platform by simplifying enterprise development, allowingloosely coupled, reliable, asynchronous interactions among Java EE components and legacy systems capableof messaging. A developer can easily add new behavior to a Java EEapplication that has existing business events by adding a new message-driven bean tooperate on specific business events. The Java EE platform, moreover, enhances the JMSAPI by providing support for distributed transactions and allowing for the concurrent consumption ofmessages. For more information, see the Enterprise JavaBeans specification, v3.0.

The JMS provider can be integrated with the application server using the JavaEE Connector architecture. You access the JMS provider through a resource adapter. Thiscapability allows vendors to create JMS providers that can be plugged in tomultiple application servers, and it allows application servers to support multiple JMS providers.For more information, see the Java EE Connector architecture specification, v1.5.

PreviousContentsNext

Copyright © 2010, Oracle and/or its affiliates. All rights reserved.Legal Notices


[8]ページ先頭

©2009-2025 Movatter.jp