[英]How to rename the id header of a debezium mongodb connector outbox message
I am trying to use the outbox event router of debezium for mongodb.我正在尝试将 debezium 的发件箱事件路由器用于 mongodb。 The consumer is a spring cloud stream application.
消费者是一个 Spring Cloud Stream 应用程序。 I cannot deserialize the message because spring cloud expects the message id header to be UUID, but it receives byte[].
我无法反序列化消息,因为 spring cloud 期望消息 id 标头是 UUID,但它接收到 byte[]。 I have tried different deserializers to no avail.
我尝试了不同的反序列化器无济于事。 I am thinking of renaming the id header in order to skip this spring cloud check, or remove it altogether.
我正在考虑重命名 id 标头以跳过此春季云检查,或完全删除它。 I have tried the ReplaceField SMT but it does not seem to modify the header fields.
我已经尝试过 ReplaceField SMT,但它似乎没有修改标题字段。
Also is there a way to overcome this in spring?春天有没有办法克服这个问题?
The solution to the initial question is to use the DropHeaders SMT( https://docs.confluent.io/platform/current/connect/transforms/dropheaders.html ).最初问题的解决方案是使用 DropHeaders SMT( https://docs.confluent.io/platform/current/connect/transforms/dropheaders.html )。 This will remove the id header that is populated by debezium.
这将删除由 debezium 填充的 id 标头。
But as Oleg Zhurakousky mentioned, moving to a newer version of spring-cloud-stream without @StreamListener solves the underlying problem.但正如 Oleg Zhurakousky 所提到的,在没有 @StreamListener 的情况下迁移到新版本的 spring-cloud-stream 可以解决根本问题。 Apparently @StreamListener checks if a message has an id header and it demands to be of type Uuid.
显然,@StreamListener 检查消息是否具有 id 标头,并且它要求是 Uuid 类型。 By using the new functional way of working with spring-cloud-stream, the id header is actually overwritten with a new generated value.
通过使用 spring-cloud-stream 的新功能方式,id 标头实际上被新生成的值覆盖。 This means that the value populated by debezium (the id column form the outbox table) is ignored.
这意味着由 debezium 填充的值(发件箱表中的 id 列)将被忽略。 I guess if you need to check for duplicate delivery, maybe it is better to create your own header instead of using the id.
我想如果您需要检查重复交付,也许最好创建自己的标题而不是使用 id。 I do not know if spring-cloud-stream generates the same id for the same message if it is redelivered.
我不知道 spring-cloud-stream 是否会为相同的消息生成相同的 id,如果它被重新传递。
Also keep in mind that even in the newer versions of spring-cloud-stream, if you use the deprecated @StreamListener, you will have the same problem.还要记住,即使在较新版本的 spring-cloud-stream 中,如果您使用已弃用的 @StreamListener,您也会遇到同样的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.