RocketMQ官方文档翻译-3

  • Post author:
  • Post category:其他



Core Concept

RocketMQ model

From the above model, we can look deeper into some topics about messaging system design:

  • Consumer Concurrency
  • 消费者并发
  • Consumer Hot Issues
  • 消费热点问题
  • Consumer Load Balance
  • 消费者的负载平衡
  • Message Router
  • 信息路由对象
  • Connection Multiplex
  • 连接复用
  • Canary Deployments


Producer

生产者

A producer sends messages generated by the business application systems to brokers.

RocketMQ provides multiple paradigms of sending: synchronous, asynchronous and one-way.

生产者把业务应用系统产生的信息发送给broker。rocketmq提供发送多个范式:同步、异步、单向。


Producer Group

生产者组

Producers of the same role are grouped together.

A different producer instance of the same producer group may be contacted by a broker to commit or roll back a transaction in case the original producer crashed after starting the transaction.

同一角色的生产组合在一起。

同一生产者组的 不同的生产者实例 可以通过broker提交或回滚事务的情况下,原始的生产开始交易后坠毁联系。

一类 Producer 的集合名称,这类 Producer 通常发送一类消息,且发送逻辑一致。

通常具有同样属性(处理的消息种类-topic、以及消息处理逻辑流程—分布式多个客户端)的一些producer可以归为同一个group。

在事务消息 机制中,如果发送某条消息的producer-A宕机,使得事务消息一直处于PREPARED状态并超时,则broker会回查同一个group的其他producer,确认这条消息应该commit 还是 rollback。


Warning

: Considering the provided producer is sufficiently powerful at sending messages, only one instance is allowed per producer group and process to avoid unnecessarily initializing of producer instances.


Consumer

A Consumer pulls messages from brokers and feeds them into application.

In perspective of user application, two types of consumers are provided:

一个消费者从broker中拉取消息,然后返还给应用???

在用户应用的角度来看,有两种类型的消费者:

消息消费者,负责消费消息,一般是后台系统负责异步消费。


PullConsumer

Pull consumer actively pulls messages from brokers. Once batches of messages are pulled, user application initiates consuming process.

Consumer 的一种,应用通常主动调用 Consumer 的拉消息方法从 Broker 拉消息,主动权由应用控制。


PushConsumer

推型消费者

Push consumer, on the other hand, encapsulates message pulling, consuming progress maintaining and other effortful work inside, leaving a callback interface to end user to implement which will be executed on message arrival.

Consumer 的一种,应用通常向 Consumer 对象注册一个 Listener 接口,一旦收到消息,Consumer 对象立刻回调。

Listener 接口方法。


Consumer Group

Similar to previously mentioned producer group, consumers of the exactly same role are grouped together and named

Consumer Group

.

类似于前面提到的生产者组的完全相同的作用,消费者被组合在一起并命名

消费组

Consumer Group is a great concept with which achieving goals of load-balance and fault-tolerance, in terms of message consuming, is super easy.

消费群体是一个很大的概念,实现了负载平衡和容错性,在信息消费方面,超容易。


Warning

: consumer instances of a consumer group

must

have exactly same topic subscription(s).


Topic

Topic is a category to which producers deliver messages and from which consumers pull messages.

Topics have very loose relation with producers and consumers. Specifically, a topic may have zero, one or multiple producers that sends messages to it; conversely, a producer can sends messages of different topics.

In consumer’s view, a topic may be subscribed by zero, one or multiple consumer groups; and a consumer group, in the same paradigm, may subscribe one or multiple topics as long as instances of this group keep their subscription consistent as emphasized in the previous section.

Topic 是一个类别的生产商提供的信息,从消费者将消息。主题与生产者和消费者非常松散的关系。具体而言,一个Topic可以有零个、一个或多个生产者发送消息到它;相反,生产者可以将不同主题的信息。

在消费者的角度,一个话题可能是订阅的零,一个或多个消费群体;和一个消费群体,在同一范式,可以订阅一个或多个主题,只要这组的情况下保持他们的订阅一致如前一节中强调。

消息的逻辑管理单位


Message

Message is the envelope of your information to deliver.

A message must be specified with a topic, which can be interpreted as address of your letter to mail to.

A message may also have an optional tag set. Extra key-value pairs may also be included. For example, you may set a business key for your message and look up the message on broker server to diagnose issues during development.

消息是信息传递的信封。一个消息必须与指定的topic,这可以理解为你的信寄到的地址。

消息也可以有一个可选的标记集。额外的键-值对,也可以包括。例如,你可以设置你的邮件业务重点和查找信息代理服务器来诊断问题中发展。


Message Queue

Topic, internally, is logically partitioned into one or more sub-topics. We call these sub-topics “message queues”. This concept plays a major role in implementing valuable features, including fail-over, maximum concurrency, etc.

Topic在逻辑上划分成一个或更多的 子Topic 。我们称这些子Topic “消息队列 message queues” 。这一概念在实现有价值的功能起着重要的作用,包括失败,最大的并发性,等等。

消息的物理管理单位。一个Topic下可以有多个Queue,Queue的引入使得消息的存储可以分布式集群化,具有了水平扩展能力。

在 RocketMQ 中,所有消息队列都是持久化,长度无限的数据结构,所谓长度无限是挃队列中的每个存储单元都是定长,访问其中的存储单元使用 Offset 来访问,offset 为 java long 类型,64 位,理论上在 100年内不会溢出,所以认为是长度无限,另外队列中只保存最近几天的数据,之前的数据会按照过期时间来删除。

也可以认为 Message Queue 是一个长度无限的数组,offset 就是下标。


Tag

Tag, which can be thought as sub-topic, provides an extra flexibility for user.

Through introducing tag, messages with different purposes from the same business module may have the same topic yet different tag. It would be helpful to keep your code clean and coherent.

标签,这可以被认为是子topic,为用户提供一个额外的灵活性。

通过引入标签,从同一个业务模块的不同用途的消息可能有相同的话题,但不同的标签。这将有助于使您的代码保持干净和相干。


Broker

Broker is the major role of the RocketMQ system. It receives messages sent from producers, store them and being prepared to serve pull requests from consumers. It also stores message consuming related meta data, including consumer groups, consuming progress offsets and topic / queue info.

Broker在rocketmq系统中起主要作用。它接收来自生产者的信息,存储和准备 拉的请求 从而为消费者服务。它还存储信息消费相关的元数据,包括消费群体的消费进度偏差和主题/队列信息。


Name Server

Name server serves as the routing information provider. Producer/Consumer clients look up topics to find broker list to read from and write to.

名称服务器作为路由信息的提供者。生产者/消费者客户端 查找经纪人名单来读写主题。


Message Model

  • Clustering

  • Broadcasting


Message Order

When DefaultMQPushConsumer is employed, you may decide to consume messages orderly or concurrently.

  • Orderly

Consuming messages orderly means messages are consumed the same order they are sent by producers for each message queue. If you are dealing with scenario that global order is mandatory, make sure the topic you use has only one message queue.


Warn

: If consuming orderly is specified, the maximum concurrency of message consuming is the number of message queues subscribed by the consumer group.

  • Concurrently

When consuming concurrently, maximum concurrency of message consuming is only limited by thread pool specified for each consumer client.


Warn

: Message order is no longer guaranteed in this mode.

转载于:https://my.oschina.net/ZZKAJ23/blog/876203