0
votes

I'm using Spring Cloud Edgware and Spring Cloud DataFlow 1.2.3.

I'm having problems with contentType and originalContentType and, although I have a workaround, I'm not understanding why it's needed.

I have various dataflow streams all sinking data to a rabbit sink, 1.3.1.RELEASE of spring-cloud-starter-stream-sink-rabbit (call it datasink for the purposes of this explanation). Rabbit source in play is 1.3.1.RELEASE of spring-cloud-starter-stream-source-rabbit.

The data in the rabbit sink is correctly application/json. The streams producing the data have Processors which munge stuff and explicitly set the output contentType to application/json in the code. This has all been working correctly for over a year and still does.

There is now a need to introduce a bridge between the datasink and another rabbit sink. The new bridge stream is simply:

rabbit-source | rabbit-sink

where rabbit-source reads from the aforementioned datasink.

The sinked data in the bridge stubbornly has a contentType of application/octet-stream.

I have tried the following setting:

app.rabbit-source.spring.cloud.stream.bindings.output.content-type=application/json

This results in a sinked contentType of application/json but the payload is base64 encoded! Why is base64 encoding happening?

My workaround is to hack the rabbit sink and to programmatically overwrite the contentType header with the originalContentType header if present. I don't like this at all and would welcome a better solution and more understanding.

1

1 Answers

1
votes

Sorry you're having an issue. Content-type negotiations have improved dramatically in the later versions of spring-cloud-stream and have been completely revamped in the 2.0 branch. So, before going any further I would recommend upgrading to the latest GA version of spring-cloud-stream which is Ditmars.SR3 and see if that alone will address your issue, or even better to the latest 2.0 snapshot (we are very close to RC, so it is pretty stable).