Skip to Content
微服务与事件驱动架构
book

微服务与事件驱动架构

by Adam Bellemare
October 2021
Beginner to intermediate
250 pages
7h 11m
Chinese
Posts & Telecom Press
Content preview from 微服务与事件驱动架构
36
3
不要在一个事件流中混合不同的事件类型,尤其是在演化上不兼容的事件类
型。事件流的创建开销很低,逻辑分离对于确保消费者在处理事件时拥有完
整的信息和明确的定义非常重要。
考虑到旧的事件流不再有新的事件产生,每个消费服务的消费者最终都将消费完所有事
件。随着时间的推移,流的事件保留期到达后最终将导致流的完全清除,此时所有消费者
都可以注销自己,并且可以删除事件流。
3.2
 选择事件格式
虽然有许多选项可用于格式化和序列化事件数据,但数据契约最好使用定义明确的格式
(如
A
vro
Thrift
Protobuf
)来实现。一些最流行的事件代理框架支持序列化和反序列
化用这些格式编码的事件。例如,
Apache
Kafka
Apache Pulsar
支持
JSON
Protobuf
Avro schema
格式
。支持这两种事件代理的机制是
schema
注册,
14.5
节会对此进行更详细
的介绍。虽然对这些序列化选项的详细评估和比较超出了本书的范围,但是有许多在线资
源可以帮助你在这些选项中做出决策。
你可能倾向于选择一个更灵活的选项,也就是使用简单的键
/
值对表示纯文本的事件格式
它提供了一些结构,但是没有提供显式的
schema
schema
演化框架
。然而,这种方法要
谨慎使用,因为它会损害微服务通过强大的数据契约保持彼此隔离的能力,而导致需要更
多的团队间沟通。
非结构化的纯文本事件通常会成为生产者和消费者的负担,尤其是用例和数
据会随着时间的推移而发生变化。如前所述,建议选择支持受控的
schema
演化的强定义、显式的 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

监控运维实践:原则与策略

监控运维实践:原则与策略

Mike Julian
Kafka权威指南

Kafka权威指南

Neha Narkhede, Gwen Shapira, Todd Palino
Web容量规划之美

Web容量规划之美

Arun Kejariwal, John Allspaw

Publisher Resources

ISBN: 9787115571106