简体   繁体   English

支持为 spring 云中的每个消费者绑定定义 spring.json.key.type

[英]Support for defining spring.json.key.type for each consumer binding in spring cloud stream bindings

After following the JsonSerdeExample I was able to directly consume the data from topics into my Java Objects.在遵循JsonSerdeExample之后,我能够将主题中的数据直接使用到我的 Java 对象中。 The following properties did all the magic以下属性完成了所有的魔法

 spring.json.key.default.type: com.xxxx.datamapper.domain.FormUUID
 spring.json.value.default.type: com.xxxx.datamapper.domain.FormData

However, now I want to run two stream listeners in a single spring boot application.但是,现在我想在单个 spring 启动应用程序中运行两个 stream 侦听器。 To do so I need a similar configuration for each consumer binding.为此,我需要为每个消费者绑定进行类似的配置。 Does spring cloud support this? spring 云是否支持这个?

As of now for the second stream, I have to consume using String serializer and then do the mapping using Object mapper.到目前为止,对于第二个 stream,我必须使用字符串序列化程序进行消费,然后使用 Object 映射器进行映射。 This makes the application code convoluted with unnecessary transformation.这使得应用程序代码与不必要的转换变得复杂。

That sample defines the Serdes at the binder level, you can also set them at the binding level该示例在绑定级别定义了 Serdes,您还可以在绑定级别设置它们

spring.cloud.stream.kafka.streams.bindings.foo.consumer.key-serde=
spring.cloud.stream.kafka.streams.bindings.foo.consumer.value-serde=

To override the setting at the binder level.在活页夹级别覆盖设置。

Similarly, you can set properties for the Serdes the same way.同样,您可以以相同的方式设置 Serdes 的属性。

spring.cloud.stream.kafka.streams.bindings.foo.consumer.configuration.spring.json...

You can define the Serde at the binder level and properties at the binding level too.您也可以在绑定级别定义 Serde,也可以在绑定级别定义属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM