jms pub/sub模型

In this post, we are going to discuss Messaging Models supported by Java Messaging System (JMS). Before reading this post, please go through my previous post about JMS to understand some JMS Basic concepts.

在这篇文章中,我们将讨论Java消息系统(JMS)支持的消息模型。 在阅读本文之前,请仔细阅读我以前关于JMS的文章,以了解一些JMS Basic概念。

JMS消息传递模型 (JMS Messaging Models)

JMS API supports two kinds of Messaging models (Programming models) to support Asynchronous Messaging between Heterogeneous Systems.

JMS API支持两种消息传递模型(编程模型)以支持异构系统之间的异步消息传递。

  • Point-To-Point Model(P2P Model)点对点模型(P2P模型)
  • Publish-Subscribe Model(Pub/Sub Model)发布-订阅模型(Pub / Sub模型)

JMS Messaging Models

JMS消息传递模型

点对点消息传递模型 (Point-to-Point Messaging Model)

Point-to-Point Messaging Model is also known as P2P Model. Below diagram shows typical Point-To-Point Messaging model in any Messaging system.

点对点消息传递模型也称为P2P模型。 下图显示了任何消息系统中的典型点对点消息模型。

JMS P2P Messaging Model

JMS P2P消息传递模型

P2P模型如何运作? (How a P2P Model works?)

Point-To-Point model follows these concepts:

点对点模型遵循以下概念:

  • P2P Model uses “Queue” as JMS DestinationP2P模型使用“队列”作为JMS目标
  • In P2P Model, a JMS Sender or JMS Producer creates and sends messages to a Queue.在P2P模型中,JMS发送者或JMS生产者创建消息并将消息发送到队列。
  • JMS Queue is an administered object, which is created in a JMS Provider by Administrator.JMS队列是一个管理对象,由管理员在JMS提供程序中创建。
  • In P2P Model, a JMS Receiver or JMS Consumer receives and reads messages from a Queue.在P2P模型中,JMS接收器或JMS使用者从队列接收和读取消息。
  • In P2P Model, a JMS Message is delivered to one and only one JMS Consumer.在P2P模型中,JMS消息仅传递给一个JMS使用者。
  • We can configure any number of JMS Senders and JMS Receivers to a particular queue. However, any message should be delivered to one and only one Receiver.我们可以将任意数量的JMS发送器和JMS接收器配置到特定队列。 但是,任何消息都应传递给一个接收方,也只能传递给一个接收方。
  • There is no timing dependency between JMS Sender and JMS receiver. That means the JMS Receiver can consume the messages whether it is alive or not when the JMS Sender sent that message.JMS Sender和JMS接收器之间没有时间依赖性。 这意味着当JMS发送方发送该消息时,无论该消息是否存在,JMS接收器都可以使用该消息。
  • In this model, Destination stores messages till its consumed by Receiver.在此模型中,目标存储消息,直到接收方将其消耗为止。

可能的P2P模型消息系统 (Possible P2P Model Messaging systems)

In this section, we will discuss “What are the possible ways to implement P2P Messaging Model”.

在本节中,我们将讨论“实现P2P消息传递模型的可能方法是什么”。

Approach 1: In this P2P Approach, we have configured one sender and one receiver. It is a very simple and straightforward approach as there is only a one-to-one connection.

方法1 :在此P2P方法中,我们配置了一个发送方和一个接收方。 这是一种非常简单明了的方法,因为只有一对一的连接。

One sender sends messages to queue and receiver receives those messages.

一个发送者将消息发送到队列,接收者接收这些消息。

JMS P2P Model – Approach 1

JMS P2P模型–方法1

Approach 2: In this P2P Model, we have configured one sender and multiple receivers. However, communication will happen between one sender to one receiver only. If the sender sends a message to Receiver-1, then only that Receiver (i.e. Receiver-1) receives that message and sends ACK (Acknowledgement) back to the Sender.

方法2 :在此P2P模型中,我们配置了一个发送方和多个接收方。 但是,通信只会在一个发送者与一个接收者之间发生。 如果发送方向接收方1发送消息,则只有该接收方(即接收方1)接收该消息,并将ACK(确认)发送回发送方。

JMS P2P Model – Approach 2

JMS P2P模型–方法2

Approach 3: In this P2P Model, we have configured multiple Senders and only one Receiver. However, communication will happen one sender to one receiver only.

方法3 :在此P2P模型中,我们配置了多个发件人和一个接收者。 但是,通信只会发生一个发送者到一个接收者。

JMS P2P Model – Approach 3

JMS P2P模型–方法3

Approach 4: In this P2P Model, we have configured multiple senders and multiple receivers. However, communication will happen between one sender to one receiver only. If Sender-2 sends a message to Receiver-2, then only that Receiver (i.e. Receiver-2) receives that message and sends ACK (Acknowledgement) back to the Sender-2.

方法4 :在此P2P模型中,我们配置了多个发送者和多个接收者。 但是,通信只会在一个发送者与一个接收者之间发生。 如果发送方2向接收方2发送消息,则只有该接收方(即接收方2)接收到该消息,然后将ACK(确认)发送回发送方2。

JMS P2P Model – Approach 4

JMS P2P模型–方法4

  • A P2P model may have more than one sender and more than one receiver, but each message is consumed by one and only one receiver.P2P模型可能有一个以上的发送方和一个以上的接收方,但是每条消息仅由一个接收方使用。
  • P2P Model Multiple Receivers

    P2P模型多接收器

    Even though this queue has more than one receiver, but each message is consumed by only one Receiver. For example, “Msg1” is only consumed by “JMS Receiver 3”.

    即使此队列有多个接收方,但是每条消息仅由一个接收方使用。 例如,“ Msg1”仅由“ JMS Receiver 3”使用。

  • Sometimes, same JMS client may act as a JMS Sender or a JMS Receiver.有时,同一JMS客户端可以充当JMS发送方或JMS接收方。

发布/订阅消息传递模型 (Publish/Subscribe Messaging Model)

Pub/Sub Messaging model is again divided into two categories.

发布/订阅消息传递模型再次分为两类。

  • Durable Messaging Model: Durable Model is also known as Persistent Messaging Model. In this model, Messages are stored in some kind of store in JMS Server until they are delivered to the destination properly.持久消息模型 :持久模型也称为持久消息模型。 在此模型中,消息将存储在JMS Server中的某种存储中,直到将它们正确地传递到目标为止。
  • Non-Durable Messaging Model: Non-Durable Model is also known as Non-Persistent Messaging Model. In this model, Messages are not stored in the JMS Server.非持久消息传递模型 :非持久消息传递模型也称为非持久消息传递模型。 在此模型中,消息未存储在JMS服务器中。

JMS Pub Sub Messaging Model

JMS Pub子消息传递模型

The following diagram shows a typical Publish/Subscribe messaging system.

下图显示了典型的发布/订阅消息传递系统。

JMS Pub Sub Example

JMS Pub子示例

发布/订阅模型如何工作 (How Pub/Sub Model Works)

  • Pub/Sub model uses Topic as JMS Destination.发布/订阅模型使用Topic作为JMS目标。
  • JMS Administrator uses JMS Provider Admin Console and configures all required ConnectionFactory and Topics Objects in JMS Provider.JMS管理员使用JMS Provider管理控制台并在JMS Provider中配置所有必需的ConnectionFactory和Topics对象。
  • JMS Publisher creates and publishes messages to Topics.JMS Publisher创建消息并将其发布到主题。
  • JMS Subscriber subscribes to interested Topics and consumes all messages.JMS订阅服务器订阅感兴趣的主题并使用所有消息。
  • Pub/Sub Messaging model has timing dependency. That means JMS Subscriber can consume messages which are published to the Topic only after it subscribes to that Topic. Any messages posted before its subscription or any messages posted when it is inactive, cannot be delivered to that Consumer.发布/订阅消息传递模型具有时间依赖性。 这意味着JMS订阅服务器只能在订阅该主题之后才能使用发布到该主题的消息。 订阅之前发布的任何消息或非活动时发布的任何消息都无法传递给该使用者。
  • Unlike P2P Model, in this model Destination does not store messages.与P2P模型不同,在此模型中,目标不存储消息。

Just like P2P Model, Pub/Sub model also contains many possible architectures:

就像P2P模型一样,Pub / Sub模型也包含许多可能的体系结构:

  • One Publisher and many Subscribers一个发布者和多个订阅者
  • Many Publishers and one Subscriber许多发布者和一个订阅者
  • Many Publishers and many Subscribers许多出版商和许多订户

P2P和发布/订阅消息传递模型之间的差异 (Differences between P2P and Pub/Sub Messaging Model)

The following table explains the major differences between the two JMS Messaging Models.

下表说明了两种JMS消息传递模型之间的主要区别。

S.No. Point-To-Point Messaging Model Publish/Subscribe Messaging Model
1. Each message is delivered to one and only one JMS Receiver Each message is delivered to multiple Consumers.
2. P2P Model has no timing dependency. Pub/Sub model has some timing dependency.
3. JMS Receiver sends acknowledgements to JMS Sender once it receives messages. Acknowledgement is not required.
序号 点对点消息传递模型 发布/订阅消息传递模型
1。 每条消息仅传递给一个JMS接收器 每个消息都传递给多个使用者。
2。 P2P模型没有时序依赖性。 Pub / Sub模型具有一些时序依赖性。
3。 一旦收到消息,JMS接收器就会向JMS发送方发送确认。 不需要确认。

翻译自: https://www.journaldev.com/9743/jms-messaging-models

jms pub/sub模型

jms pub/sub模型_JMS消息传递模型:点对点和发布/订阅相关推荐

  1. springboot整合ActiveMQ(点对点和发布订阅)

    springboot整合ActiveMQ(点对点和发布订阅) ActiveMQ是什么,为什么使用MQ 是基于 Java 中的 JMS 消息服务规范实现的一个消息中间件. 1.系统解耦 采用中间件之后, ...

  2. 消息队列中点对点与发布订阅区别

    背景知识 JMS一个在 Java标准化组织(JCP)内开发的标准(代号JSR 914).2001年6月25日,Java消息服务发布JMS 1.0.2b,2002年3月18日Java消息服务发布 1.1 ...

  3. 消息队列中点对点与发布订阅区别(good)

    背景知识 JMS一个在 Java标准化组织(JCP)内开发的标准(代号JSR 914).2001年6月25日,Java消息服务发布JMS 1.0.2b,2002年3月18日Java消息服务发布 1.1 ...

  4. MQ - 消息队列中点对点模型与发布/订阅模式的区别

    背景知识 JMS一个在 Java标准化组织(JCP)内开发的标准(代号JSR 914).2001年6月25日,Java消息服务发布JMS 1.0.2b,2002年3月18日Java消息服务发布 1.1 ...

  5. 消息队列模式(点对点发布订阅)

    Java消息服务(Java Message Service,JMS)应用程序接口是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送消息,进行异步通信. ...

  6. 3,ActiveMQ-入门(基于JMS发布订阅模型)

    一.Pub/Sub-发布/订阅消息传递模型 在发布/订阅消息模型中,发布者发布一个消息,该消息通过topic传递给所有的客户端.在这种模型中,发布者和订阅者彼此不知道对方,是匿名的且可以动态发布和订阅 ...

  7. 为什么lp的最优解是一个概率_什么时候应该用概率图模型、消息传递替代传统组合优化求解器?未来工作?(持续更新)...

    相关基础:概率图模型中的推断https://zhuanlan.zhihu.com/p/252169479 英文原文:https://tspace.library.utoronto.ca/bitstre ...

  8. kafka 发布订阅_在Kafka中发布订阅模型

    kafka 发布订阅 这是第四个柱中的一系列关于同步客户端集成与异步系统( 1, 2, 3 ). 在这里,我们将尝试了解Kafka的工作方式,以便正确利用其发布-订阅实现. 卡夫卡概念 根据官方文件 ...

  9. 在Kafka中发布订阅模型

    这是第四个柱中的一系列关于同步客户端集成与异步系统( 1, 2, 3 ). 在这里,我们将尝试了解Kafka的工作方式,以便正确利用其发布-订阅实现. 卡夫卡概念 根据官方文件 : Kafka是一种分 ...

最新文章

  1. Android内存管理之道
  2. golang odbc mysql_golang使用odbc链接hive
  3. 开课吧python小课值得么-领导想提拔你,从来看的不是努力!
  4. 直接启动SDK Manager: $ADNROID_HOME/tools/android
  5. python中的魔法属性和方法
  6. 如何让nodejs同步操作
  7. android布局添加背景颜色,android-获取布局的背景色
  8. python 文案自动生成_Python应用 | 利用COM技术自动生成IBM i2舞弊关系分析图表
  9. click Utilities
  10. WCF走你~一个简单的例子,根据用户ID,从用户模块(用户服务器)获得实体
  11. android 开发不容错过的网站
  12. Spring Boot文件目录介绍
  13. ABAP-内表数据下载到CSV格式(原创转载请注明)
  14. IBM面试题试解(关于50条狗、50个人、病狗)
  15. BNU 背包密码(编码与解密)
  16. cpu多开测试软件,教你用多核CPU多开畅玩大型3D游戏
  17. 中华老黄历下载手机版免费_中华老黄历下载安装到手机-中华老黄历软件下载5.4.5 官方下载最新版-东坡下载...
  18. 这45道面试可能被问到的JS判断题!你能答对几道?
  19. Objective-C 属性
  20. 6-3 sdust-Java-模拟主板、USB口、TypeC口、PS2口设备 (20 分)

热门文章

  1. LNMP环境下压力测试时的主要调试参数
  2. WinFrom 中 label背景透明
  3. SPQuery如何消除重复记录(实现联动性)
  4. [转载] Python水平自测!100道经典练习题.pdf(附答案)
  5. [转载] python解析返回结果_python:解析requests返回的response(json格式)说明
  6. MATLAB IIR滤波器设计函数buttord与butter
  7. Django之模型层
  8. IP 层收发报文简要剖析1-ip报文的输入
  9. Alpha阶段-个人总结
  10. 基本运算符中Swift和Java的比较