Search code examples
spring-integrationspring-cloud-dataflow

Spring Data Flow JDBC Sink JSON


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());

Solution

  • 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.