Pulsar Messages 消息的组成部分

        Pulsar 基于发布-订阅模式(通常缩写为pub-sub),在这种模式中, 生产者(producers)将消息(messages)发布到主题(topics);消费者(consumers)订阅这些主题(topics),然后处理传入消息(messages),并在处理完成后向代理(broker)发送确认信息。

        当消费者订阅消息后,即使消费者断开连接,Pulsar 也会保留所有的消息。只有当消费者确认所有消息都已经成功处理,Pulsar 才会丢弃保留的消息

        假如有一条消息消费失败,消费者又想再次消费这条消息,可以开启消息重传机制,请求broker 重新发送这条消息。

消息(messages)组成

        消息(messages)是 Pulsar 的基本“单位”。下表列出了消息的组成部分:

ComponentDescription
Value / data payload

The data carried by the message. All Pulsar messages contain raw bytes, although message data can also conform to data schemas.

// 消息携带的数据。所有Pulsar消息都包含原始字节,尽管消息数据也可以符合数据模式。

Key

The key (string type) of the message. It is a short name of message key or partition key. Messages are optionally tagged with keys, which is useful for features like topic compaction.

// ​消息的键(字符串类型)。它是消息key或分区key的简称。消息可以选择使用键进行标记,这对于压缩主题等都非常有用。

Properties

An optional key/value map of user-defined properties.

// 一个可供用户自定义的键值对属性

Producer name

The name of the producer who produces the message. If you do not specify a producer name, the default name is used.

// 生成消息的生产者的名称。如果未指定生产者名称,则使用默认名称。

Topic nameThe name of the topic that the message is published to.
Schema version

The version number of the schema that the message is produced with.

// 生成消息时使用的架构的版本号。

Sequence ID

Each Pulsar message belongs to an ordered sequence on its topic. The sequence ID of a message is initially assigned by its producer, indicating its order in that sequence, and can also be customized.

// 每一条Pulsar message在topic中都有一个有序序列,序列ID默认由其生产者分配,指示其在该序列中的顺序,也可以自定义。
Sequence ID can be used for message deduplication. If brokerDeduplicationEnabled is set to true, the sequence ID of each message is unique within a producer of a topic (non-partitioned) or a partition.

// 序列ID可用于消除消息的重复数据。如果BrokerDeplicationEnabled设置为true,则每个消息的序列ID在主题(非分区)或分区的生产者中是唯一的。

Message ID

The message ID of a message is assigned by bookies as soon as the message is persistently stored. Message ID indicates a message’s specific position in a ledger and is unique within a Pulsar cluster.

// 消息ID持久化时由bookies分配,指定消息在消息分类中的特定位置,并且在Pulsar 集群中是唯一的。

Publish time

The timestamp of when the message is published. The timestamp is automatically applied by the producer.

// 消息发布时间,该时间由生产者自动提供

Event time

An optional timestamp attached to a message by applications. For example, applications attach a timestamp on when the message is processed. If nothing is set to event time, the value is 0.

// 应用程序附加到消息的可选时间戳。例如,应用程序在处理消息时附加时间戳。如果未将任何内容设置为事件时间,则该值为0。

        消息(messages)的默认大小为 5 MB。也可以使用以下配置,配置消息的大小。

        在 broker.conf 文件中:

# The max size of a message (in bytes).
maxMessageSize=5242880

        在 bookkeeper.conf 文件中:

# The max size of the netty frame (in bytes). Any messages received larger than this value are rejected. The default value is 5 MB.
nettyMaxFrameSizeBytes=5253120

        For more information on Pulsar messages, see Pulsar binary protocol.

点击回到首页

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值