消息总线和消息队列理解 [英] Message bus and Message queue understanding

查看:32
本文介绍了消息总线和消息队列理解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我对消息总线和消息队列工作的理解是否正确.

I would like to know if my understanding of Message Bus and Message Queue workings is correct.

首先,我需要明确命名,服务总线消息总线可以互换使用吗?这是一个发布者 - 订阅者类型的系统,其中添加了消息,让我们说任意数量的发布者可以从其中读取任意数量的订阅者的消息集合,到目前为止我是对的吗?

First thing first, I need to clear the naming, a service bus is used interchangeably with message bus? It is a publisher-subscriber type of system where messages are added let's say to a message collection by any number of publishers and from where any number of subscribers can read, am i right so far ?

P1 ---                                         /``````S1
       \________ Service Bus Middleware ------+------ S2
       /           MESSAGE-COLLECTION          \______S3
P2 ---

我不明白的是

  1. 订阅者如何知道它对什么消息感兴趣,我的意思是它显然订阅了它,但是它如何知道它应该订阅哪些消息?,它在哪里看到消息列表,这是如何提供给它的?通过带有或如何使用的 API ?

  1. how does a subscriber know what message it is interested in, I mean it subscribes to it obviously, but how does it know to which message(s) it should subscribe?, Where does it see the message list, how is this available to it? via an API with or how ?

订阅者如何收到消息?

何时从 MESSAGE-COLLECTION 中删除消息?我可以想象的是,为每条消息保留了一些计数器,该计数器表示订阅者的总数,一旦一个订阅者成功处理了该消息,该总数就会减少.

when is a message removed from MESSAGE-COLLECTION? What I can imagine is that some counter is kept for each message, the counter represents the total number of subscribers which gets decremented as soon as one subscriber successfully processed the message.

消息队列,也称为消息代理,是一种推拉式系统.有任意数量的生产者和任意数量的消费者.每个生产者为每个消费者创建一个队列,向其提供消息.

A message queue also known as a message-broker is a push-pull type of system. There are any number of producers and any number of consumers. Each producer creates a queue per consumer to which it feeds messages.

             --- Message Queue 1 ---- C1
           /  
P1 ------ +
           \ 
             --- Message Queue 2 ---- C2


P2 ------ + --- Message Queue 1 ---- C1

在这种情况下,一旦消费者成功处理消息,消息就会被删除.我的消息队列对其工作原理的理解是否正确?

Since this is the case, the message gets removed as soon as the consumer successfully processes it. Are my message queue understanding of its workings correct ?

另一个我不确定究竟是做什么的概念是事件中心.

Another concept that I'm not sure of what exactly does is event hub.

推荐答案

我想知道我对消息总线和消息队列工作的理解是否正确.

I would like to know if my understanding of Message Bus and Message Queue workings is correct.

一些评论/答案.这不会很全面,因为很多方面都特定于所使用的队列.

Some comments/answers. This is not going to be comprehensive as many aspects are specific to the queue being used.

服务总线与消息总线可以互换使用吗?

a service bus is used interchangeably with message bus?

没错.服务总线是面向服务的解决方案中使用的消息总线基础设施,提供服务之间的后端数据传输机制.

Right. A service bus is a message bus infrastructure used in service-oriented solution, providing the back-end data transport mechanism between the services.

这是一种发布者 - 订阅者类型的系统,其中添加了消息,例如由任意数量的发布者和任意数量的订阅者可以读取的消息集合

It is a publisher-subscriber type of system where messages are added let's say to a message collection by any number of publishers and from where any number of subscribers can read

一般有两种模式:

1) 发布/订阅,发布者在没有特定目标的情况下将数据发送到总线.然后,一个或多个订阅者可以消费该消息(或不消费,见下文).

1) Publish/Subscribe, where a publisher sends data to a bus without a specific target in mind. One or more subscribers can then consume the message (or not, see below).

2) 请求/响应,发送方将数据发送到总线,但期望接收到的特定对象来处理消息并返回响应.

2) Request/Response, where a senders sends the data to the bus but expects a specific received to handle the message and return a response.

订阅者如何知道它对什么消息感兴趣...?

how does a subscriber know what message it is interested in...?

大多数服务总线实现使用路由键的概念.发送到总线的每个数据实体都附带一个密钥,然后订阅者可以通过该密钥进行过滤.

Most service bus implementations use the concept of routing keys. Each data entity sent to the bus is accompanied by a key that the subscribers can then filter by.

当然,订阅者也可以选择将所有消息发布到特定队列.

Of course, subscribers may also choose to get all messages posted to a particular queue.

订阅者如何收到消息?

这因服务队列产品而异.例如,在 RabbitMQ 中,消息通过 API 传递给订阅者,而在 Kafka 中,客户端必须定期轮询服务器以获取消息.

This varies among service queue products. In RabbitMQ, for example, messages are delivered to a subscriber by the API whereas in Kafka, the client must poll the server periodically for messages.

何时从 MESSAGE-COLLECTION 中删除消息?

when is a message removed from MESSAGE-COLLECTION?

有时根本不是.这也因产品和配置而异.有时一条消息只传递给一个接收者,一旦确认传递就被删除,但有时消息会留在总线上,直到它们根据时间戳过期.许多场景都是可能的.

Sometimes not at all. This also varies both between products and configurations. Sometimes a message is delivered to only one receiver and is deleted once delivery has been confirmed, but sometimes messages are left on the bus until they are expired based on a time stamp. Many scenarios are possible.

这篇关于消息总线和消息队列理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆