I using camel reactive streams and I would like to add content type APPLICATION_JSON_UTF8_VALUE for the response. I tried to add it in map function. Here is my code.
@Autowired
private CamelReactiveStreamsService camel;
camel.process("rest:post:test", exchangeProperty ->
Flux.from(exchangeProperty)
.map(ex -> {
ex.getIn().setHeader(Exchange.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE);
return ex;
})
.map(ex -> ex.getIn().getBody(String.class))
.flatMap(camel.toStream("testRest", String.class))
.doOnNext(ex -> System.out.println(ex)));
This code returns only text without Header "content type" I think I don't understand how it works, so will be nice if someone can send me a link with tutorial(because I can't find), or someone can help me understand it. Thank you for help
.map(ex -> ex.getIn().getBody(String.class))will lead to the remaining stream to operate on the result of the mapping, which is the body of the exchange as String object, and therefore you'll lose any other information available within the exchange, such as the header