如何使用 kafka 模式管理和 Avro 进行重大更改 [英] How to use kafka schema management and Avro for breaking changes

查看:21
本文介绍了如何使用 kafka 模式管理和 Avro 进行重大更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

带有 avro 的 kafka 模式管理为我们提供了向后兼容性的灵活性,但我们如何处理方案中的重大更改?

kafka schema management with avro give us flexibility to backward compatibility but how do we handle breaking-changes in the scheme?

假设生产者 A 向消费者 C 发布消息 M

Assume Producer A publish messages M to Consumer C

假设消息 M 的方案发生了重大变化(例如,名称字段现在被拆分为 first_name 和 last_name)并且我们有了新的方案 M-New

assume message M has a breaking change in it's scheme (e.g name field is now splitted into first_name and last_name) and we have new scheme M-New

现在我们正在部署生产者 A-New 和消费者 C-New

Now we are deploying producer A-New and Consumer C-New

问题是,在我们的部署过程完成之前,我们可以让生产者 A-new 发布消息 M-new,而消费者 C(旧的)将收到 M-new,因此我们可能会丢失消息.

problem is that until our deployment process finish we can have Producer A-new publish message M-new where Consumer C (the old one) will receive the M-new and we can lose message because of that.

所以唯一的方法是同步新生产者和消费者的部署,这会增加很多开销

So the only way to do this is to sync the deployment of new producers and consumers which is adding lots of overhead

有什么建议可以处理吗?

any suggestions how to handle that?

推荐答案

一种简单的方法是为您的主题设置较长的保留期.然后,您只需为重大更改创建一个新主题.所有消费者都可以在保留期内移动到新主题而不会丢失消息.

An easy way would be to have a long retention period for your topics. Then you just create a new topic for the breaking changes. All consumers can move to the new topic within the retention period without losing messages.

这篇关于如何使用 kafka 模式管理和 Avro 进行重大更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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