文件名称:JMS(Java Message Service)教程.pdf
文件大小:763KB
文件格式:PDF
更新时间:2014-08-25 10:41:32
JMS 教程
第1章 JMS基本概念...................................................................................................................1 1.1 什么是JMS(JAVA MESSAGE SERVICE)?.........................................................................1 1.2 什么是JMS中的消息(MESSAGING)?..............................................................................1 1.3 如何实现JMS客户端程序的跨平台性?...........................................................................2 1.4 有关两种消息方式简介......................................................................................................2 1.5 开发一个基于JMS的消息客户端应用的编程步骤...........................................................4 1.6 JMS有关多线程方面的问题..........................................................................................4 第2章 JMS 消息模型.................................................................................................................6 2.1 背景:.................................................................................................................................6 2.2 目标:.................................................................................................................................6 2.3 JMS 消息..............................................................................................................................6 2.4 消息头字段..........................................................................................................................7 2.4.1 JMSDestination..............................................................................................................7 2.4.2 JMSDeliveryMode..........................................................................................................7 2.4.3 JMSMessageID...............................................................................................................7 2.4.4 JMSTimestamp...............................................................................................................7 2.4.5 JMSCorrelationID..........................................................................................................8 2.4.6 JMSReplyTo....................................................................................................................8 2.4.7 JMSRedelivered..............................................................................................................9 2.4.8 JMSType........................................................................................................................9 2.4.9 JMSExpiration................................................................................................................9 2.4.10 JMSPriority..................................................................................................................9 2.4.11 对消息头信息如何被设置的总结...........................................................................10 2.4.12 重载消息头字段.......................................................................................................10 2.5 消息属性............................................................................................................................10 2.5.1 属性名.........................................................................................................................10 2.5.2 属性值.........................................................................................................................10 2.5.3 使用属性.....................................................................................................................11 2.5.4 属性值的转换.............................................................................................................11 2.5.5 属性值作为对象.........................................................................................................11 2.5.6 属性迭代.....................................................................................................................12 2.5.7 清空消息属性值.........................................................................................................12 2.5.8 不存在的属性.............................................................................................................12 2.5.9 JMS定义的属性...........................................................................................................12 2.5.10 提供者指定的属性...................................................................................................14 2.6MESSAGE 确认....................................................................................................................14 2.7 消息接口............................................................................................................................14 2.8MESSAGE 选择....................................................................................................................14 2.8.1 Message 选择器..........................................................................................................14 2.8.2 消息选择语法.............................................................................................................15 2.8.3 Null Values 空值..........................................................................................................18 2.8.4 特别说明.....................................................................................................................18 2.9 访问被发送的消息............................................................................................................19 I JMS 规范教程 2.10 改变已接收的消息的值..................................................................................................19 2.11 JMS消息体........................................................................................................................19 2.11.1 清空消息体...............................................................................................................20 2.11.2 “只读消息体”............................................................................................................20 2.11.3 由StreamMessage和MapMessage提供的转换功能.................................................20 第3章 JMS通用设施.................................................................................................................22 3.1ADMINISTERED OBJECTS被管理的对象..............................................................................22 3.1.1 Destination目的地.......................................................................................................22 3.1.2 ConnectionFactory 连接工厂。...............................................................................23 3.2 CONNECTION 连接.............................................................................................................23 3.2.1 Authentication认证......................................................................................................23 3.2.2 Client Identifier客户端标识........................................................................................23 3.2.3 Connection Setup连接的建立......................................................................................24 3.2.4 Pausing Delivery of Incoming Messages 停止传送即将到来的消息.......................24 3.2.5 Closing a Connection 关闭连接.................................................................................25 3.2.6 Sessions 会话..............................................................................................................26 3.2.7 ConnectionMetaData...................................................................................................26 3.2.8 ExceptionListener异常监听器.....................................................................................26 3.3 SESSION会话........................................................................................................................26 3.3.1 Closing a Session关闭会话.........................................................................................27 3.3.2 MessageProducer 和 MessageConsumer 的创建....................................................28 3.3.3 Creating Temporary Destinations 创建临时目的地..................................................28 3.3.4 Creating Destination Objects创建目的地对象。.......................................................28 3.3.5 Optimized Message Implementations 优化消息的实现。.......................................28 3.3.6 Conventions for Using a Session 使用Session的常规................................................28 3.3.7 Transactions 事务.......................................................................................................29 3.3.8 Distributed Transactions 分布事务............................................................................30 3.3.9 Multiple Sessions 多会话............................................................................................30 3.3.10 Message Order 消息顺序.........................................................................................30 3.3.11 Message Acknowledgment 消息确认........................................................................31 3.3.12 Duplicate Delivery of Messages 重复的消息传送...................................................32 3.3.13 Duplicate Production of Messages 重复的消息生产...............................................32 3.3.14 Serial Execution of Client Code 顺序执行客户端代码...........................................32 3.3.15 Concurrent Message Delivery 并发消息传送..........................................................33 3.4MESSAGECONSUMER 消息消费者......................................................................................33 3.4.1 Synchronous Delivery 同步传送.................................................................................33 3.4.2 Asynchronous Delivery 异步传送...............................................................................33 3.5MESSAGEPRODUCER 消息生产者.......................................................................................34 3.6 MESSAGE DELIVERY MODE 消息传送模式......................................................................34 3.7 MESSAGE TIME-TO-LIVE 消息存活时间..........................................................................35 3.8 EXCEPTIONS 异常..............................................................................................................35 3.9 RELIABILITY 可靠性...........................................................................................................35 第4章 JMS点对点传输模式.....................................................................................................37 4.1 OVERVIEW概述...................................................................................................................37 4.2 QUEUE MANAGEMENT(队列管理)................................................................................37 II JMS 规范教程 4.3 QUEUE(队列)................................................................................................................38 4.4 TEMPORARYQUEUE............................................................................................................38 4.5 QUEUECONNECTIONFACTORY...........................................................................................38 4.6 QUEUECONNECTION...........................................................................................................38 4.7 QUEUESESSION..................................................................................................................38 4.8 QUEUERECEIVER................................................................................................................38 4.9 QUEUEBROWSER...............................................................................................................39 4.10 QUEUEREQUESTOR..........................................................................................................39 4.11 RELIABILITY 可靠性.......................................................................................................39 第5章 JMS发布/订阅(PUBLISH/SUBSCRIBE)模式...................................................40 5.1 OVERVIEW概述....................................................................................................................40 5.2 PUB/SUB LATENCY 延迟......................................................................................................40 5.3 DURABLE SUBSCRIPTION 持久化的订阅............................................................................41 5.4 TOPIC MANAGEMENT 主题管理..........................................................................................41 5.5 TOPIC 主题..........................................................................................................................41 5.6 TEMPORARYTOPIC................................................................................................................42 5.7 TOPICCONNECTIONFACTORY................................................................................................42 5.8 TOPICCONNECTION..............................................................................................................42 5.9 TOPICSESSION.....................................................................................................................42 5.10 TOPICPUBLISHER................................................................................................................42 5.11 TOPICSUBSCRIBER..............................................................................................................43 5.11.1 Durable TopicSubscriber 持久化的主题订阅..........................................................43 5.12 RECOVERY AND REDELIVERY 恢复和重发........................................................................43 5.13ADMINISTERING SUBSCRIPTIONS 管理定阅......................................................................44 5.14 TOPICREQUESTOR..............................................................................................................44 5.15 RELIABILITY 可靠性.........................................................................................................44 第6章 SUN MQ安装及配置.....................................................................................................46 6.1 安装注意事项....................................................................................................................46 6.2 JMS 服务管理代理并创建各种目的地对象....................................................................46 6.2.1 创建JMS服务管理代理..............................................................................................46 6.2.2 创建目的地.................................................................................................................48 6.3 配置开发所需环境............................................................................................................48 6.3.1 建立基于JNDI的管理对象存储环境........................................................................48 6.3.2 在LDAP中存储目的地和连接工厂...........................................................................51 第7章基于发布/订阅模式的应用范例....................................................................................52 7.1 背景...................................................................................................................................52 7.2 实现...................................................................................................................................52