`
单眼皮大娘
  • 浏览: 110999 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

JMS 基础概念(一)

    博客分类:
  • JMS
阅读更多
A JMS application is composed of the following parts.

      1) A JMS provider is a messaging system that implements the JMS interfaces and provides administrative and control features. An implementation of the J2EE platform at release 1.3 and later includes a JMS provider.
      2)JMS clients are the programs or components, written in the Java programming language, that produce and consume messages. Any J2EE application component can act as a JMS client.
      3) Messages are the objects that communicate information between JMS clients.
      4) Administered objects are preconfigured JMS objects created by an administrator for the use of clients. The two kinds of JMS administered objects are destinations and connection factories, which are described in Administered Objects.
Figure 33-2 illustrates the way these parts interact. Administrative tools allow you to bind destinations and connection factories into a JNDI namespace. A JMS client can then look up the administered objects in the namespace and then establish a logical connection to the same objects through the JMS provider.

说明:JSM provider指的是实现JMS接口的第三方软件(比如activemq),我们的编程是在这基础上。工程代码中实现自己的生产者、消费者的逻辑代码。这有些类似一个开源框架pushlet,服务器端由用户自定义事件的产生(生产者),而客户端只需要实现相应的function即可(消费者)。( Administered objects 在下一篇文章中阐述)



          
Messaging Domains

     Before the JMS API existed, most messaging products supported either the point-to-point or the publish/subscribe approach to messaging. The JMS specification provides a separate domain for each approach and defines compliance for each domain. A stand-alone JMS provider can implement one or both domains. A J2EE provider must implement both domains.

     In fact, most implementations of the JMS API support both the point-to-point and the publish/subscribe domains, and some JMS clients combine the use of both domains in a single application. In this way, the JMS API has extended the power and flexibility of messaging products.

      The JMS 1.1 specification goes one step further: It provides common interfaces that enable you to use the JMS API in a way that is not specific to either domain. The following subsections describe the two messaging domains and then describe this new way of programming using common interfaces.

      Point-to-Point Messaging Domain
      A point-to-point (PTP) product or application is built on the concept of message queues, senders, and receivers. Each message is addressed to a specific queue, and receiving clients extract messages from the queues established to hold their messages. Queues retain all messages sent to them until the messages are consumed or until the messages expire.

     


     Point-to-Point Messaging的特性:
     1)Each message has only one consumer.
     2)A sender and a receiver of a message have no timing dependencies. The receiver can fetch the message whether or not it was running when the client sent the message.
     3)he receiver acknowledges the successful processing of a message.
     Use PTP messaging when every message you send must be processed successfully by one consumer

     Publish/Subscribe Messaging Domain
     In a publish/subscribe (pub/sub) product or application, clients address messages to a topic, which functions somewhat like a bulletin board. Publishers and subscribers are generally anonymous and can dynamically publish or subscribe to the content hierarchy. The system takes care of distributing the messages arriving from a topic's multiple publishers to its multiple subscribers. Topics retain messages only as long as it takes to distribute them to current subscribers.

         

     Publish/Subscribe Messaging的特性:
     1)Each message can have multiple consumers.
     2)Publishers and subscribers have a timing dependency. A client that subscribes to a topic can consume only messages published after the client has created a subscription, and the subscriber must continue to be active in order for it to consume messages.

说明:Point-to-Point Messaging和Publish/Subscribe Messaging关于timing dependency,前者没有依赖关系,而后者必须有依赖关系,订阅者必须要在订阅的主题产生之前才能有效接受相应的消息,而且订阅者必须是在active状态才能接受消息;前者则没有这种制约,消息会一直保存知道订阅者获取消息或者设置的时间戳期限到。前者发布消息后,分发给活动状态的订阅者,消息销毁。

The JMS API relaxes this timing dependency to some extent by allowing subscribers to create durable subscriptions, which receive messages sent while the subscribers are not active. Durable subscriptions provide the flexibility and reliability of queues but still allow clients to send messages to many recipients.

Message Consumption

     Messaging products are inherently asynchronous: There is no fundamental timing dependency between the production and the consumption of a message. However, the JMS specification uses this term in a more precise sense. Messages can be consumed in either of two ways:
     1)Synchronously: A subscriber or a receiver explicitly fetches the message from the destination by calling the receive method. The receive method can block until a message arrives or can time out if a message does not arrive within a specified time limit.
     2)Asynchronously: A client can register a message listener with a consumer. A message listener is similar to an event listener. Whenever a message arrives at the destination, the JMS provider delivers the message by calling the listener's onMessage method, which acts on the contents of the message.

【注意】:时间依赖关系和消费信息方式(同步或者异步)是两个不同的概念
         1) 时间依赖关系是指的生产者(发布者)和消费者(订阅者)之间的先后顺序(信息产生是在信息订阅之前还是之后)以及消费者是否处于活动状态;
         2)消费信息方式是指消费者是等待直到有消息产生呢还是个干个的事情,直到有消费产生我在回过头处理相应的消息。

JMS的基本概念了解后,后一篇阐述 The JMS API Programming Model
    
  • 大小: 18.4 KB
  • 大小: 10.2 KB
  • 大小: 17.4 KB
分享到:
评论

相关推荐

    JMS入门文档,JMS入门文档

    三分关于jms的入门文档,适合初步了解jms的基本概念,和浅层的架构体系。

    JMS 教程 - 消息队列、消息服务

    本教程描述了消息服务的概念和一些应用事例,说明了 JMS 的基本概念和结构,并就消息服务的发布/订阅、点对点模式编写了简单代码,最后讨论的JMS的一些高级问题,如食物、可靠性、可恢复性等。

    WSAD环境下JMS异步通信全攻略

    一、JMS基本概念  1.1 P2P通信  1.2 Pub/Sub通信 二、JMS消息 三、JMS P2P编程  3.1 使用JMS QueueConnection对象  3.2 处理回退事件  3.3 关闭JMS对象  3.4 接收消息  3.5 消息驱动的Bean...

    JMS与MDB介绍

    JMS与MDB介绍 基本概念 JMS编程模型 MDB介绍

    深入浅出JMS-JMS介绍说明文档

    深入浅出JMS,主要介绍J2EE中的一个重要规范JMS,因为这个规范在企业中的应用十分的广泛,也比较重要,我们主要介绍JMS的基本概念和它的模式,消息的消费以及JMS编程步骤。

    有关JMS/或j2ee技术的说明与问题

    JMS(Java Messaging Service)是Java平台上有关面向消息中间件的技术规范,翻译为Java消息服务。JMS支持点对点和发布/订阅两种消息模型。 编辑本段JMS基本概念

    activemq新手大全

    一、JMS基本概念 二、activemq介绍及安装 1、消息中间件简介 2、activemq 2.1、activemq简介 2.2、activemq下载 2.3、运行activemq服务 2.4、测试 2.5、监控 3、activemq特性 4、activemq使用场景 三、...

    [ActiveMQ]消息中间件基本概念及安装

    ActiveMQ是一个完全支持JMS1.1和J2EE1.4规范的JMSProvider实现,它非常快速,支持多种语言的客户端和协议,而且可以非常容易的嵌入到企业的应用环境中,并有许多高级功能。首先简单的介绍一下MQ,MQ英文名Message...

    RabbitMQ技术详解

    本文来自于网络,本文主要介绍了RabbitMQ是什么,RabbitMQ为何会出现,RabbitMQ基础概念,RabbitMQ集群等。RabbitMQ是一个开源的AMQP实现,服务器端用Erlang语言编写,支持多种客户端,如:Python、Ruby、.NET、Java...

    实战ActiveMQ集群与应用视频教程.zip

    2:JMS基本概念和模型 3:JMS的可靠性机制 4:JMS的API结构和开发步骤 5:Broker的启动方式 6:ActiveMQ结合Spring开发 7:ActiveMQ支持的传输协议 8:ActiveMQ消息存储持久化 9:ActiveMQ的静态网络链接 10:多线程...

    ActiveMQ.rar

    包括:基本概念、消息结构、可靠性机制、PTP、Pub/Sub、API结构、JMS应用开 发的基本步骤、持久和非持久的Topic等 n 四:用ActiveMQ构建应用 包括:多种启动Broker的方法、单独应用的开发、结合Spring的开发等 n 五...

    Java基本概念名词一览

     J2EE是JAVA 2 PLATform ENTERPRISE EDITIONS的简称,它是一个套件,它很有可能成为服务器端的标准。包含有:  Enterprise JavaBeans(EJB)  JavaServer Pages(JSP)  JDBC  Java Message Service(JMS)  ...

    Spring in Action中文版 清晰pdf part2

    第一部分展示了Spring框架的两个核心概念:反向控制(Inverstion of Control,IoC)和面向切面编程(Aspect-Oriented Programming,AOP),以便读者理解Spring的基础原理,这些基础原理在本书各个章节都会用到。...

    Spring in Action中文版 清晰pdf part1

    第一部分展示了Spring框架的两个核心概念:反向控制(Inverstion of Control,IoC)和面向切面编程(Aspect-Oriented Programming,AOP),以便读者理解Spring的基础原理,这些基础原理在本书各个章节都会用到。...

    经典JAVA.EE企业应用实战.基于WEBLOGIC_JBOSS的JSF_EJB3_JPA整合开发.pdf

    4.2.1 事务的基本概念 191 4.2.2 分布式事务处理、XA规范和 2PC协议 192 4.2.3 使用JTA全局事务保证多 数据库的一致性 193 4.3 事务隔离、传播属性的设置 198 4.3.1 并发访问和隔离 198 4.3.2 事务属性 199 4.4 EJB...

    从Java走向Java+EE+.rar

    第1章 Java EE的基本知识...23.2 测试的基本概念 320 23.3 利用JUnit进行单元测试 324 23.4 利用StrutsTestCase对Struts进行测试 328 23.5 压力测试和JMeter 334 23.6 其他开源测试工具 339 23.7 小结 343

    java基础题 很全面

    45. 线程的基本概念、线程的基本状态以及状态之间的关系 12 46. 在linux下 怎么查看tomcat的进程? 12 47. 简述逻辑操作(&,|,^)与条件操作(&&,||)的区别。 12 48. XML文档定义有几种形式?它们之间有何本质区别?解析...

    Java 2技术内幕(Part1)

    全书贯穿了一个用Java 编写的实际应用,可供读者理解Java的各种概念和编程方法,并且所有源代码可以从网上下载。本书适合有一定Java语言基础的编程人员使用。 主要内容: 使用Enterprise JavaBean(EJB)开发可伸缩的...

    Java 2技术内幕(Part2)

    全书贯穿了一个用Java 编写的实际应用,可供读者理解Java的各种概念和编程方法,并且所有源代码可以从网上下载。本书适合有一定Java语言基础的编程人员使用。 主要内容: 使用Enterprise JavaBean(EJB)开发可伸缩的...

Global site tag (gtag.js) - Google Analytics