1
votes

I've created a custom sink off of the 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:

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

I'm using the property jdbc.columns as follows:

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());
1
Which version of app starters you are using? This is known issue - Oleg Zhurakousky
I'm using org.springframework.cloud.stream.app:spring-cloud-starter-stream-sink-jdbc:2.1.0.RELEASE - dardo

1 Answers

3
votes

There's an improvement required to explicitly handle payloads of different kinds starting from the 2.0.x release of jdbc app-starters.

We are tracking that via 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.