`
单眼皮大娘
  • 浏览: 113194 次
  • 性别: 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的基本概念 ##### 1. 消息模型 JMS支持两种消息模型:点对点(Point-to-Point, P2P)和发布/订阅(Publish-Subscribe, Pub/Sub)。 - **点对点模型**:在该模型中,消息由一个或多个生产者发送到一个...

    JMS消息模型 JMS学习.doc

    Java 消息服务(JMS,Java Message Service)是一种用于在分布式系统中进行异步数据交换的API,它为应用程序提供了标准的接口来发送和接收消息。...理解和掌握JMS的基本概念和用法,对于开发企业级Java应用至关重要。

    JMS学习笔记(一)——JMS简介安装ActiveMQ

    **JMS核心概念** 1. **消息(Message)**:是JMS的核心,它是一个数据结构,用于封装要传递的信息。消息可以是文本、二进制数据或对象。 2. **消息队列(Message Queue)**:消息被发送到消息队列,然后由消费者从队列中...

    JMS的一个非常好的demo

    1. **点对点(Point-to-Point)模型**:这是JMS的基本模型之一,其中消息从一个生产者发送到一个队列,然后由一个或多个消费者接收。每个消息仅被一个消费者处理。在这个demo中,可能包含了创建生产者、消费者,以及...

    JMS入门文档,JMS入门文档

    1. **JMS基本概念**: - **消息**:JMS中的基本单元,它是一个数据对象,包含要传递的信息。 - **消息生产者**(Message Producer):负责创建和发送消息的组件。 - **消息消费者**(Message Consumer):接收并...

    JMS demo 及 资料

    在"JMS入门级的蹩脚篇.ppt"这个文件中,可能包含了以下内容:JMS的基本概念解释,如何创建消息,如何设置消息队列和主题,如何编写生产者和消费者代码示例,以及如何配置和运行JMS应用程序。这些内容对于初学者理解...

    JMS规范教程pdf

    #### 一、JMS基本概念 **1.1 什么是JMS(JAVA MESSAGE SERVICE)?** JMS,即Java Message Service,是Java平台中的消息服务应用标准,允许应用程序组件通过Java消息服务进行通信。它为分布式系统提供了消息传递和...

    jms-1.1.jar

    一、JMS核心概念 1. 消息:在JMS中,消息是数据传输的基本单元,它封装了要传递的信息。消息可以包含文本、二进制数据或任何Java对象。 2. 消息生产者(Message Producer):负责创建并发送消息的组件,通常是一个...

    OSB中JMS配置及队列使用说明

    同时,需要了解基本的 JMS 概念和 OSB 的基本配置。 JMS 及消息队列概要介绍 JMS 是 Java 平台上的一种消息服务规范,允许 Java 应用程序创建、发送、接收和读取消息。JMS 提供了两种类型的消息模型:点对点模型和...

    一个很好的jms教程

    ### 一、JMS基础 1. **消息模型**:JMS支持两种基本的消息模型——点对点(Point-to-Point, PTP)和发布/订阅(Publish/Subscribe, Pub/Sub)。点对点模型中,消息从一个生产者发送到一个队列,由一个或多个消费者...

    一个简单的JMS客户端应用

    Java消息服务(Java Message Service,简称JMS)是Java平台中用于企业级应用间异步通信的一种标准API。它允许应用程序创建、发送、接收和读取...理解并掌握这些基本概念和操作是构建高效、可扩展的企业级应用的关键。

    JBOSS建立JMS应用实例

    一、JMS基础知识 1. 概念理解:JMS是Java平台中用于企业级消息传递的API,它定义了生产、发送、接收和消费消息的标准接口。 2. 消息模型:JMS支持两种消息模型——点对点(Point-to-Point)和发布/订阅(Publish/...

    Java-JMS实例

    **JMS基本概念** 1. **JMS API**:JMS 提供了一组接口和类,使得开发者能够创建、发送、接收和消费消息。它定义了生产者(Producer)和消费者(Consumer)的概念,生产者负责创建和发送消息,消费者则负责接收和...

    Jms基础知识整理创建消息 -> 发送消息 -> 接收消息 -> 读取消息 ()

    【JMS基础知识详解:创建、发送、接收与读取消息】 Java消息服务(Java Message Service,简称JMS)是一个标准接口,它定义了应用程序如何创建、发送、接收和读取消息的标准API。JMS允许分布式系统中的不同组件通过...

    jms-1.1.jar(jms工具jar包)

    JMS的核心概念主要包括以下几点: 1. **消息**:在JMS中,消息是数据传输的基本单元,它封装了要传递的信息。消息可以是文本、二进制或其他复杂的数据结构。 2. **消息生产者(Message Producer)**:负责创建和...

    JMS 简单使用指南

    2. **JMS基本概念**: - **消息**:消息由消息主体(数据)和消息标题(元数据,包含目标、有效期等属性)组成。 - **消息服务体系结构**:JMS定义了两种主要的消息传送模型——点对点(Point-to-Point, PTP)和...

    JMS的中文教程(Java的消息驱动)

    掌握JMS的基本概念、架构和应用场景对于任何希望在分布式环境中构建稳定、高性能系统的Java开发者来说都是至关重要的。此外,随着技术的发展,JMS也在不断进化,例如引入了更多的安全特性和消息分组的支持等。这些都...

    spring-jms入门

    本文将深入探讨Spring-JMS的基础知识,包括它的核心概念、配置以及如何与ActiveMQ这样的消息中间件进行集成。 **1. JMS简介** Java消息服务(Java Message Service,简称JMS)是一个标准,定义了应用程序如何创建、...

    JMS标准规范培训教程

    《JMS规范培训教程》这份文档很可能是深入理解JMS标准和实际应用的指南,它可能涵盖了JMS的基本概念、API用法、消息模型的比较、事务处理、消息持久化、故障恢复策略等内容。通过学习这份教程,开发者能够熟练地在...

    JMS 学习资源

    #### 一、JMS 基本概念与通信模型 JMS(Java Message Service)是一种广泛应用于企业级应用程序之间的消息传递标准,它定义了一系列接口,用于创建、发送、接收消息。JMS 的设计目标是简化应用程序之间的通信流程,...

Global site tag (gtag.js) - Google Analytics