logo资料库

jms 2.0规范.pdf

第1页 / 共148页
第2页 / 共148页
第3页 / 共148页
第4页 / 共148页
第5页 / 共148页
第6页 / 共148页
第7页 / 共148页
第8页 / 共148页
资料共148页,剩余部分请下载后查看
License
Contents
1. Introduction
1.1. Abstract
1.2. Overview
1.2.1. Is this a mail API?
1.2.2. Existing messaging systems
1.2.3. JMS objectives
1.2.3.1. JMS provider
1.2.3.2. JMS messages
1.2.3.3. JMS domains
1.2.3.4. Portability
1.2.4. What JMS does not include
1.3. What is required by JMS
1.4. Relationship to other Java APIs
1.4.1. Java DataBase Connectivity (JDBCTM) software
1.4.2. JavaBeansTM components
1.4.3. Enterprise JavaBeansTM component model
1.4.4. Java Transaction API (JTA)
1.4.5. Java Transaction Service (JTS)
1.4.6. Java Naming and Directory InterfaceTM (JNDI) API
1.4.7. Java Platform, Enterprise Edition (Java EE)
1.5. What is new in JMS 1.1?
1.6. What is new in JMS 2.0?
2. Architecture
2.1. Overview
2.2. What is a JMS application?
2.3. Administration
2.4. Two messaging styles
2.5. JMS interfaces
2.6. Developing a JMS application
2.6.1. Developing a JMS client
2.7. Security
2.8. Multi-threading
2.9. Triggering clients
2.10. Request/reply
3. JMS message model
3.1. Background
3.2. Goals
3.3. JMS messages
3.4. Message header fields
3.4.1. JMSDestination
3.4.2. JMSDeliveryMode
3.4.3. JMSMessageID
3.4.4. JMSTimestamp
3.4.5. JMSCorrelationID
3.4.6. JMSReplyTo
3.4.7. JMSRedelivered
3.4.8. JMSType
3.4.9. JMSExpiration
3.4.10. JMSPriority
3.4.11. How message header values are set
3.4.12. Overriding message header fields
3.4.13. JMSDeliveryTime
3.5. Message properties
3.5.1. Property names
3.5.2. Property values
3.5.3. Using properties
3.5.4. Property value conversion
3.5.5. Property values as objects
3.5.6. Property iteration
3.5.7. Clearing a message’s property values
3.5.8. Non-existent properties
3.5.9. JMS defined properties
3.5.10. Provider-specific properties
3.5.11. JMSXDeliveryCount
3.6. Message acknowledgment
3.7. The Message interface
3.8. Message selection
3.8.1. Message selector
3.8.1.1. Message selector syntax
3.8.1.2. Null values
3.8.1.3. Special notes
3.9. Access to sent messages
3.10. Changing the value of a received message
3.11. JMS message body
3.11.1. Clearing a message body
3.11.2. Read-only message body
3.11.3. Conversions provided by StreamMessage and MapMessage
3.11.4. Messages for non-JMS clients
3.12. Provider implementations of JMS message interfaces
4. JMS common facilities
4.1. Overview
4.2. Administered objects
4.2.1. Destination
4.2.2. ConnectionFactory
4.3. Connection
4.3.1. Authentication
4.3.2. Client identifier
4.3.3. Connection setup
4.3.4. Pausing delivery of incoming messages
4.3.5. Closing a Connection
4.3.6. Sessions
4.3.7. ConnectionMetaData
4.3.8. ExceptionListener
4.4. Session
4.4.1. Closing a Session
4.4.2. MessageProducer and MessageConsumer Creation
4.4.3. Creating temporary destinations
4.4.4. Creating Destination objects
4.4.5. Optimized message implementations
4.4.6. Conventions for using a session
4.4.7. Transactions
4.4.8. Distributed transactions
4.4.9. Multiple sessions
4.4.10. Message order
4.4.10.1. Order of message receipt
4.4.10.2. Order of message sends
4.4.11. Message acknowledgment
4.4.12. Duplicate delivery of messages
4.4.13. Duplicate production of messages
4.4.14. Serial execution of client code
4.4.15. Concurrent message delivery
4.5. MessageConsumer
4.5.1. Synchronous delivery
4.5.2. Asynchronous delivery
4.6. MessageProducer
4.7. Message delivery mode
4.8. Message time-to-live
4.9. Exceptions
4.10. Reliability
4.11. Method inheritance across messaging domains
4.12. Batch delivery
4.13. Delivery delay
5. JMS point-to-point model
5.1. Overview
5.2. Queue management
5.3. Queue
5.4. TemporaryQueue
5.5. QueueConnectionFactory
5.6. QueueConnection
5.7. QueueSession
5.8. QueueReceiver
5.9. QueueBrowser
5.10. QueueRequestor
5.11. Reliability
6. JMS publish/subscribe model
6.1. Overview
6.2. Pub/sub latency
6.3. Durable subscription
6.4. Topic management
6.5. Topic
6.6. TemporaryTopic
6.7. TopicConnectionFactory
6.8. TopicConnection
6.9. TopicSession
6.10. TopicPublisher
6.11. TopicSubscriber
6.11.1. Durable subscriptions
6.12. Recovery and redelivery
6.13. Administering subscriptions
6.14. TopicRequestor
6.15. Reliability
7. JMS exceptions
7.1. Overview
7.2. The JMSException
7.3. Standard exceptions
8. JMS application server facilities
8.1. Overview
8.2. Concurrent processing of a subscription’s messages
8.2.1. Session
8.2.2. ServerSession
8.2.3. ServerSessionPool
8.2.4. ConnectionConsumer
8.2.5. How a ConnectionConsumer uses a ServerSession
8.2.6. How an application server implements a ServerSession
8.2.7. The result
8.3. XAConnectionFactory
8.4. XAConnection
8.5. XASession
8.6. JMS application server interfaces
9. JMS example code
9.1. Preparing to send and receive messages
9.1.1. Getting a ConnectionFactory
9.1.2. Getting a Destination
9.1.3. Creating a Connection
9.1.4. Creating a Session
9.1.5. Creating a MessageProducer
9.1.6. Creating a MessageConsumer
9.1.7. Starting message delivery
9.1.8. Using a TextMessage
9.2. Sending and receiving messages
9.2.1. Sending a message
9.2.2. Receiving a message synchronously
9.2.3. Unpacking a TextMessage
9.3. Other messaging features
9.3.1. Receiving messages asynchronously
9.3.2. Using message selection
9.3.3. Using durable subscriptions
9.3.3.1. Creating a durable subscription
9.3.3.2. Reconnecting to a topic using a durable subscription
9.4. JMS message types
9.4.1. Creating a TextMessage
9.4.2. Unpacking a TextMessage
9.4.3. Creating a BytesMessage
9.4.4. Unpacking a BytesMessage
9.4.5. Creating a MapMessage
9.4.6. Unpacking a MapMessage
9.4.7. Creating a StreamMessage
9.4.8. Unpacking a StreamMessage
9.4.9. Creating an ObjectMessage
9.4.10. Unpacking an ObjectMessage
10. Use of JMS API in Java EE applications
10.1. Overview
10.2. Restrictions on the use of JMS API in the Java EE web or EJB container
10.3. Behaviour of JMS sessions in the Java EE web or EJB container
11. Simplified JMS API
11.1. Goals of the simplified API
11.2. Key features of the simplified API
11.2.1. MessagingContext
11.2.1. Static constants for session mode
11.2.2. Creating messages
11.2.3. Sending messages
11.2.4. Consuming messages asynchronously
11.2.5. Consuming messages synchronously
11.2.6. Closing the MessagingContext
11.2.7. Automatic start of message delivery
11.2.8. Threading restrictions on a MessagingContext
11.2.9. Exceptions
11.3. Injection of MessagingContext objects
11.4. Examples using the simplified API
11.4.1. Sending a message (Java EE)
11.4.1.1. Example using the standard API
11.4.1.2. Example using the simplified API
11.4.1.3. Example using the simplified API and injection
11.4.2. Sending a message (Java SE)
11.4.2.1. Example using the standard API
11.4.2.2. Example using the simplified API
11.4.3. Receiving a message synchronously (Java EE)
11.4.3.1. Example using the standard API
11.4.3.2. Example using the simplified API
11.4.3.3. Example using the simplified API and injection
11.4.4. Receiving a message synchronously (Java SE)
11.4.4.1. Example using the standard API
11.4.4.2. Example using the simplified API
11.4.5. Receiving a message synchronously from a durable subscription (Java EE)
11.4.5.1. Example using the standard API
11.4.5.2. Example using the simplified API
11.4.5.3. Example using the simplified API and injection
11.4.6. Receiving messages asynchronously (Java SE)
11.4.6.1. Example using the standard API
11.4.6.2. Example using the simplified API
11.4.7. Receiving a message asynchronously from a durable subscription (Java SE)
11.4.7.1. Example using the standard API
11.4.7.2. Example using the simplified API
11.4.8. Receiving a message in multiple threads (Java SE)
11.4.8.1. Example using the standard API
11.4.8.2. Example using the simplified API
11.4.9. Receiving synchronously and sending a message in the same local transaction (Java SE)
11.4.9.1. Example using the standard API
11.4.9.2. Example using the simplified API
11.4.10. Request/reply pattern using a TemporaryQueue (Java EE)
11.4.10.1. Example using the standard API
11.4.10.2. Example using the simplified API
11.4.10.3. Example using the simplified API and injection
A. Issues
A.1. Resolved issues
A.1.1 JDK 1.1.x compatibility
A.1.1 Distributed Java event model
A.1.2 Should the two JMS domains, PTP and pub/sub, be merged?
A.1.3 Should JMS specify a set of JMS JavaBeans?
A.1.4 Alignment with the CORBA notification service
A.1.5 Should JMS provide end-to-end synchronous message delivery and notification of delivery?
A.1.6 Should JMS provide a send-to-list mechanism?
A.1.7 Should JMS provide subscription notification?
A.2. Unresolved issues in the JMS 2.0 Early Draft
A.2.1 Simplified JMS API: Support for multiple consumers on a session
A.2.2 Simplified API: Injecting a MessagingContext
A.2.3 Batch message delivery
B. Change history
B.1. Version 1.0.1
B.1.1 JMS exceptions
B.2. Version 1.0.2
B.2.1 The multiple topic subscriber special case
B.2.2 Message selector comparison of exact and inexact numeric values
B.2.3 Connection and session close
B.2.4 Creating a session on an active connection
B.2.5 Delivery mode and message retention
B.2.6 The ‘single thread’ use of sessions
B.2.7 Clearing a message’s properties and body
B.2.8 Message selector numeric literal syntax
B.2.9 Comparison of boolean values in message selectors
B.2.10 Order of messages read from a queue
B.2.11 Null values in messages
B.2.12 Closing constituents of closed connections and sessions
B.2.13 The termination of a pending receive on close
B.2.14 Incorrect entry in Stream and Map Message conversion table
B.2.15 Inactive durable subscription
B.2.16 Read-only message body
B.2.17 Changing header fields of a received message
B.2.18 Null/missing message properties and message fields
B.2.19 JMS source errata
B.2.20 JMS source Java API documentation errata
B.2.21 JMS source Java API documentation clarifications
B.3. Version 1.0.2b
B.3.1 JMS API specification, version 1.0.2: errata and clarifications
B.3.2 JMS API Java API documentation, version 1.0.2a: major errata
B.3.2.1. Corrections of mistakes
B.3.2.2. Reconciliations between the specification and the Java API documentation
B.3.3 JMS API Java API documentation, version 1.0.2a: lesser errata
B.4. Version 1.1
B.4.1 Unification of messaging domains
B.4.2 JMS API specification, version 1.1: domain unification
B.4.3 JMS API specification, version 1.1: updates and clarifications
B.4.3.1. Updates to introduction, added figures
B.4.3.2. Clarifications
B.4.4 JMS API Java API documentation, version 1.1: domain unification
B.4.5 JMS API documentation, version 1.1: changes
B.4.5.1. New methods
B.4.5.2. Clarifications
B.5. Version 2.0
B.5.1 Re-ordering of chapters
B.5.2 JMS providers must implement both P2P and Pub-Sub (JMS_SPEC-50)
B.5.3 Use of JMS API in Java EE applications (JMS_SPEC-45 and JMS_SPEC-27)
B.5.4 New methods to create a session (JMS_SPEC-45)
B.5.5 Batch delivery (JMS_SPEC-36)
B.5.6 Delivery delay (JMS_SPEC-44)
B.5.7 Sending messages asynchronously (JMS_SPEC-43)
B.5.8 Use of AutoCloseable (JMS_SPEC-53)
B.5.9 JMSXDeliveryCount (JMS_SPEC-42)
B.5.10 Client ID optional on Durable subscriptions (JMS_SPEC-39)
B.5.11 New createDurableConsumer methods (JMS_SPEC-51)
B.5.12 Simplified API (JMS_SPEC-64)
B.5.13 Clarification: message may be sent using any session (JMS_SPEC-52)
B.5.14 Clarification: use of ExceptionListener (JMS_SPEC-49)
B.5.15 Clarification: use of stop or close from a message listener (JMS_SPEC-48)
B.5.16 Clarification: use of noLocal when creating a durable subscription (JMS_SPEC-65)
B.5.17 Clarification: message headers that are intended to be set by the JMS provder (JMS_SPEC-34)
Java Message Service The JMS API is an API for accessing enterprise messaging systems from Java programs Version 2.0 (Early Draft) Mark Hapner, Rich Burridge, Rahul Sharma, Joseph Fialli, Kate Stout Sun Microsystems (Version 1.1) Nigel Deakin Oracle (Version 2.0) 21 February 2012 Please send comments to users@jms-spec.java.net For information about how to contribute to JMS 2.0 visit http://jms-spec.java.net
License Specification: JSR-343 Java Message Service 2.0 ("Specification") Version: 2.0 Status: Early Draft Review Release: 21 February 2012 Copyright 2012 Oracle America, Inc. 500 Oracle Parkway, Redwood City, California 94065, U.S.A. All rights reserved. NOTICE The Specification is protected by copyright and the information described therein may be protected by one or more U.S. patents, foreign patents, or pending applications. Except as provided under the following license, no part of the Specification may be reproduced in any form by any means without the prior written authorization of Oracle America, Inc. ("Oracle") and its licensors, if any. Any use of the Specification and the information described therein will be governed by the terms and conditions of this Agreement. Subject to the terms and conditions of this license, including your compliance with Paragraphs 1 and 2 below, Oracle hereby grants you a fully-paid, non-exclusive, non-transferable, limited license (without the right to sublicense) under Oracle's intellectual property rights to: 1. Review the Specification for the purposes of evaluation. This includes: (i) developing implementations of the Specification for your internal, non- commercial use; (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts do not in the aggregate constitute a significant portion of the Technology. 2. Distribute implementations of the Specification to third parties for their testing and evaluation use, provided that any such implementation: (i) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented; (ii) is clearly and prominently marked with the word "UNTESTED" or "EARLY ACCESS" or "INCOMPATIBLE" or "UNSTABLE" or "BETA" in any list of available builds and in proximity to every link initiating its download, where the list or link is under Licensee's control; and (iii) Includes the following notice: "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP." The grant set forth above concerning your distribution of implementations of the specification is contingent upon your agreement to terminate development and distribution of your "early draft" implementation as soon as feasible following final completion of the specification. If you fail to do so, the foregoing grant shall be considered null and void. 2 Java Message Service Version 2.0 (Early Draft)
No provision of this Agreement shall be understood to restrict your ability to make and distribute to third parties applications written to the Specification. Other than this limited license, you acquire no right, title or interest in or to the Specification or any other Oracle intellectual property, and the Specification may only be used in accordance with the license terms set forth herein. This license will expire on the earlier of: (a) two (2) years from the date of Release listed above; (b) the date on which the final version of the Specification is publicly released; or (c) the date on which the Java Specification Request (JSR) to which the Specification corresponds is withdrawn. In addition, this license will terminate immediately without notice from Oracle if you fail to comply with any provision of this license. Upon termination, you must cease use of or destroy the Specification. "Licensor Name Space" means the public class or interface declarations whose names begin with "java", "javax", "com.oracle" or their equivalents in any subsequent naming convention adopted by Oracle through the Java Community Process, or any recognized successors or replacements thereof TRADEMARKS No right, title, or interest in or to any trademarks, service marks, or trade names of Oracle or Oracle's licensors is granted hereunder. Oracle, the Oracle logo, Java are trademarks or registered trademarks of Oracle USA, Inc. in the U.S. and other countries. DISCLAIMER OF WARRANTIES THE SPECIFICATION IS PROVIDED "AS IS" AND IS EXPERIMENTAL AND MAY CONTAIN DEFECTS OR DEFICIENCIES WHICH CANNOT OR WILL NOT BE CORRECTED BY ORACLE. ORACLE MAKES NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON- INFRINGEMENT THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE OR THAT ANY PRACTICE OR IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER RIGHTS. This document does not represent any commitment to release or implement any portion of the Specification in any product. THE SPECIFICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION THEREIN; THESE CHANGES WILL BE INCORPORATED INTO NEW VERSIONS OF THE SPECIFICATION, IF ANY. ORACLE MAY MAKE IMPROVEMENTS AND/OR CHANGES TO THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THE SPECIFICATION AT ANY TIME. Any use of such changes in the Specification will be governed by the then-current license for the applicable version of the Specification. LIMITATION OF LIABILITY TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL ORACLE OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING, PRACTICING, MODIFYING OR ANY USE OF THE License 3
SPECIFICATION, EVEN IF ORACLE AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You will hold Oracle (and its licensors) harmless from any claims based on your use of the Specification for any purposes other than the limited right of evaluation as described above, and from any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license. RESTRICTED RIGHTS LEGEND If this Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in the Software and accompanying documentation shall be only as set forth in this license; this is in accordance with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions). REPORT You may wish to report any ambiguities, inconsistencies or inaccuracies you may find in connection with your evaluation of the Specification ("Feedback"). To the extent that you provide Oracle with any Feedback, you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Oracle a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose related to the Specification and future versions, implementations, and test suites thereof. GENERAL TERMS Any action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N. Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply. The Specification is subject to U.S. export control laws and may be subject to export or import regulations in other countries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee. This Agreement is the parties' entire agreement relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party. 4 Java Message Service Version 2.0 (Early Draft)
Contents License Contents 1. Introduction 2. Architecture 1.4.1. 1.4.2. 1.4.3. 1.4.4. 1.4.5. 1.4.6. 1.4.7. 2 5 11 1.1. Abstract ................................................................................... 11 1.2. Overview ................................................................................. 11 Is this a mail API? ......................................................... 11 1.2.1. Existing messaging systems .......................................... 11 1.2.2. 1.2.3. JMS objectives .............................................................. 12 1.2.4. What JMS does not include ........................................... 13 1.3. What is required by JMS .......................................................... 14 1.4. Relationship to other Java APIs ............................................... 14 Java DataBase Connectivity (JDBCTM) software ........... 14 JavaBeansTM components .............................................. 14 Enterprise JavaBeansTM component model .................... 14 Java Transaction API (JTA) .......................................... 14 Java Transaction Service (JTS) ..................................... 14 Java Naming and Directory InterfaceTM (JNDI) API ..... 15 Java Platform, Enterprise Edition (Java EE) .................. 15 1.5. What is new in JMS 1.1? ......................................................... 15 1.6. What is new in JMS 2.0? ......................................................... 15 17 2.1. Overview ................................................................................. 17 2.2. What is a JMS application? ...................................................... 17 2.3. Administration ......................................................................... 17 2.4. Two messaging styles .............................................................. 18 2.5. JMS interfaces ......................................................................... 18 2.6. Developing a JMS application ................................................. 19 Developing a JMS client ............................................... 20 2.7. Security ................................................................................... 20 2.8. Multi-threading ........................................................................ 20 2.9. Triggering clients ..................................................................... 21 2.10. Request/reply ........................................................................... 21 22 3.1. Background .............................................................................. 22 3.2. Goals ....................................................................................... 22 3.3. JMS messages .......................................................................... 22 3.4. Message header fields .............................................................. 23 JMSDestination ............................................................. 23 3.4.1. JMSDeliveryMode ........................................................ 23 3.4.2. JMSMessageID ............................................................. 23 3.4.3. JMSTimestamp ............................................................. 23 3.4.4. JMSCorrelationID ......................................................... 24 3.4.5. JMSReplyTo ................................................................. 24 3.4.6. JMSRedelivered ............................................................ 25 3.4.7. JMSType ....................................................................... 25 3.4.8. JMSExpiration .............................................................. 25 3.4.9. 3.4.10. JMSPriority ................................................................... 26 3.4.11. How message header values are set ............................... 26 3.4.12. Overriding message header fields .................................. 26 2.6.1. 3. JMS message model Contents 5
3.4.13. 3.5.1. 3.5.2. 3.5.3. 3.5.4. 3.5.5. 3.5.6. 3.5.7. 3.5.8. 3.5.9. 3.5.10. 3.5.11. JMSDeliveryTime ......................................................... 27 3.5. Message properties .................................................................. 27 Property names ............................................................. 27 Property values ............................................................. 27 Using properties ............................................................ 27 Property value conversion ............................................. 27 Property values as objects ............................................. 28 Property iteration .......................................................... 28 Clearing a message’s property values ............................ 28 Non-existent properties ................................................. 29 JMS defined properties.................................................. 29 Provider-specific properties .......................................... 30 JMSXDeliveryCount ..................................................... 30 3.6. Message acknowledgment........................................................ 31 3.7. The Message interface ............................................................. 31 3.8. Message selection .................................................................... 31 3.8.1. Message selector ........................................................... 31 3.9. Access to sent messages ........................................................... 36 3.10. Changing the value of a received message ............................... 36 3.11. JMS message body ................................................................... 36 3.11.1. Clearing a message body ............................................... 37 3.11.2. Read-only message body ............................................... 37 3.11.3. Conversions provided by StreamMessage and 4. JMS common facilities 4.2.1. 4.2.2. 4.3.1. 4.3.2. 4.3.3. 4.3.4. 4.3.5. 4.3.6. 4.3.7. 4.3.8. MapMessage ................................................................. 37 3.11.4. Messages for non-JMS clients ....................................... 38 3.12. Provider implementations of JMS message interfaces .............. 39 40 4.1. Overview ................................................................................. 40 4.2. Administered objects ............................................................... 40 Destination .................................................................... 40 ConnectionFactory ........................................................ 41 4.3. Connection ............................................................................... 41 Authentication ............................................................... 41 Client identifier ............................................................. 42 Connection setup ........................................................... 42 Pausing delivery of incoming messages ........................ 43 Closing a Connection .................................................... 43 Sessions ........................................................................ 44 ConnectionMetaData ..................................................... 44 ExceptionListener ......................................................... 45 4.4. Session ..................................................................................... 45 4.4.1. Closing a Session .......................................................... 46 4.4.2. MessageProducer and MessageConsumer Creation ....... 47 Creating temporary destinations .................................... 47 4.4.3. Creating Destination objects ......................................... 47 4.4.4. 4.4.5. Optimized message implementations ............................ 47 Conventions for using a session .................................... 48 4.4.6. Transactions .................................................................. 49 4.4.7. 4.4.8. Distributed transactions ................................................. 49 4.4.9. Multiple sessions ........................................................... 50 4.4.10. Message order ............................................................... 50 4.4.11. Message acknowledgment ............................................. 51 4.4.12. Duplicate delivery of messages ..................................... 51 4.4.13. Duplicate production of messages ................................. 52 4.4.14. Serial execution of client code ...................................... 52 4.4.15. Concurrent message delivery ........................................ 52 4.5. MessageConsumer ................................................................... 52 6 Java Message Service Version 2.0 (Early Draft)
5. JMS point-to-point model 6. JMS publish/subscribe model 4.5.1. 4.5.2. Synchronous delivery .................................................... 53 Asynchronous delivery .................................................. 53 4.6. MessageProducer ..................................................................... 53 4.7. Message delivery mode ............................................................ 55 4.8. Message time-to-live ................................................................ 55 4.9. Exceptions ............................................................................... 55 4.10. Reliability ................................................................................ 56 4.11. Method inheritance across messaging domains ........................ 57 4.12. Batch delivery .......................................................................... 57 4.13. Delivery delay ......................................................................... 57 59 5.1. Overview ................................................................................. 59 5.2. Queue management .................................................................. 59 5.3. Queue ...................................................................................... 60 5.4. TemporaryQueue ..................................................................... 60 5.5. QueueConnectionFactory ......................................................... 60 5.6. QueueConnection..................................................................... 60 5.7. QueueSession........................................................................... 60 5.8. QueueReceiver ......................................................................... 60 5.9. QueueBrowser ......................................................................... 61 5.10. QueueRequestor ....................................................................... 61 5.11. Reliability ................................................................................ 61 62 6.1. Overview ................................................................................. 62 6.2. Pub/sub latency ........................................................................ 62 6.3. Durable subscription ................................................................ 63 6.4. Topic management ................................................................... 63 6.5. Topic ....................................................................................... 63 6.6. TemporaryTopic ...................................................................... 64 6.7. TopicConnectionFactory .......................................................... 64 6.8. TopicConnection ...................................................................... 64 6.9. TopicSession ............................................................................ 64 6.10. TopicPublisher ......................................................................... 64 6.11. TopicSubscriber ....................................................................... 65 6.11.1. Durable subscriptions .................................................... 65 6.12. Recovery and redelivery .......................................................... 66 6.13. Administering subscriptions ..................................................... 66 6.14. TopicRequestor ........................................................................ 66 6.15. Reliability ................................................................................ 67 68 7.1. Overview ................................................................................. 68 7.2. The JMSException ................................................................... 68 7.3. Standard exceptions ................................................................. 68 70 8.1. Overview ................................................................................. 70 8.2. Concurrent processing of a subscription’s messages ................ 70 Session .......................................................................... 70 ServerSession ................................................................ 71 ServerSessionPool ......................................................... 71 ConnectionConsumer .................................................... 71 How a ConnectionConsumer uses a ServerSession........ 72 How an application server implements a ServerSession ................................................................ 72 8.2.1. 8.2.2. 8.2.3. 8.2.4. 8.2.5. 8.2.6. 7. JMS exceptions 8. JMS application server facilities Contents 7
9. JMS example code 8.2.7. 9.1.1. 9.1.2. 9.1.3. 9.1.4. 9.1.5. 9.1.6. 9.1.7. 9.1.8. The result ...................................................................... 72 8.3. XAConnectionFactory ............................................................. 74 8.4. XAConnection ......................................................................... 74 8.5. XASession ............................................................................... 74 8.6. JMS application server interfaces ............................................. 75 76 9.1. Preparing to send and receive messages ................................... 76 Getting a ConnectionFactory ......................................... 76 Getting a Destination .................................................... 77 Creating a Connection ................................................... 77 Creating a Session ......................................................... 77 Creating a MessageProducer ......................................... 78 Creating a MessageConsumer ....................................... 78 Starting message delivery .............................................. 78 Using a TextMessage .................................................... 78 9.2. Sending and receiving messages .............................................. 79 Sending a message ........................................................ 79 Receiving a message synchronously .............................. 79 Unpacking a TextMessage ............................................ 79 9.3. Other messaging features ......................................................... 79 Receiving messages asynchronously ............................. 80 Using message selection ................................................ 80 Using durable subscriptions .......................................... 81 JMS message types .................................................................. 82 Creating a TextMessage ................................................ 82 9.4.1. Unpacking a TextMessage ............................................ 83 9.4.2. Creating a BytesMessage .............................................. 83 9.4.3. Unpacking a BytesMessage ........................................... 83 9.4.4. Creating a MapMessage ................................................ 83 9.4.5. Unpacking a MapMessage ............................................ 84 9.4.6. Creating a StreamMessage ............................................ 84 9.4.7. Unpacking a StreamMessage ......................................... 85 9.4.8. Creating an ObjectMessage ........................................... 85 9.4.9. 9.4.10. Unpacking an ObjectMessage ....................................... 86 87 10.1. Overview ................................................................................. 87 10.2. Restrictions on the use of JMS API in the Java EE web or EJB 9.2.1. 9.2.2. 9.2.3. 9.3.1. 9.3.2. 9.3.3. 9.4. 10. Use of JMS API in Java EE applications 11. Simplified JMS API container .................................................................................. 87 10.3. Behaviour of JMS sessions in the Java EE web or EJB container ................................................................................................ 89 92 11.1. Goals of the simplified API ...................................................... 92 11.2. Key features of the simplified API ........................................... 93 11.2.1. MessagingContext ......................................................... 93 11.2.1. Static constants for session mode .................................. 94 11.2.2. Creating messages ......................................................... 95 11.2.3. Sending messages ......................................................... 95 11.2.4. Consuming messages asynchronously ........................... 97 11.2.5. Consuming messages synchronously ............................. 99 11.2.6. Closing the MessagingContext .................................... 101 11.2.7. Automatic start of message delivery ............................ 101 11.2.8. Threading restrictions on a MessagingContextError! Bookmark not define 11.2.9. Exceptions .................................................................. 102 11.3. Injection of MessagingContext objects .................................. 102 8 Java Message Service Version 2.0 (Early Draft)
分享到:
收藏