简体   繁体   English

Spring数据流JDBC Sink JSON

[英]Spring Data Flow JDBC Sink JSON

I've created a custom sink off of the JDBC Sink Starter. 我已经从JDBC Sink Starter创建了一个自定义接收器。 The input to the sink is JSON content, but when the sink receives the message I receive the following error in the logs: 接收器的输入是JSON内容,但是当接收器收到消息时,我在日志中收到以下错误:

 Property or field 'field' cannot be found on object of type 'byte[]'

I'm using the property jdbc.columns as follows: 我正在使用属性jdbc.columns如下:

jdbc.columns=FIELD_COLUMN:field

The processor feeding the sink is sending the message as: 馈送接收器的处理器将消息发送为:

String payload = objectMapper.writeValueAsString(message);
                output.send(MessageBuilder
                        .withPayload(payload)
                        .setHeader("contentType", "application/json")
                        .build());

There's an improvement required to explicitly handle payloads of different kinds starting from the 2.0.x release of jdbc app-starters. jdbc app-starters的2.0.x版本开始,显式处理不同类型的有效负载需要进行改进。

We are tracking that via spring-cloud-stream-app-starters/jdbc#48 . 我们通过spring-cloud-stream-app-starters / jdbc#48跟踪它。 Feel free to share your thoughts/questions as comments. 随意分享您的想法/问题作为评论。

We will review and resolve it soon. 我们会尽快审核并解决。 In the meantime, please try the workaround by setting the upstream content-type as text/plain for now. 在此期间,请立即将上游内容类型设置为text/plain ,以尝试解决方法。

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

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