419ae06fb30f81d091cad8e06f4ce0b2a2ebdf93
[JavaForFun] /
1 package de.example.spring.kafka;
2
3 import org.springframework.messaging.converter.MappingJackson2MessageConverter;
4 import org.springframework.util.MimeType;
5
6 /**
7  * Working around problem created by org.springframework.cloud.stream.binder.AbstractBinder.JavaClassMimeTypeConversion.mimeTypeFromObject()
8  *
9  * This code:
10  *                      if (payload instanceof String) {
11  *                              return MimeTypeUtils.APPLICATION_JSON_VALUE.equals(originalContentType) ? MimeTypeUtils.APPLICATION_JSON
12  *                                              : MimeTypeUtils.TEXT_PLAIN;
13  *                      }
14  *
15  * Changes messages from: 
16  * contentType "application/json;charset=UTF-8"{"name":"example message","description":"this is some description"}
17  * 
18  * to:
19  * contentType "text/plain" originalContentType "application/json;charset=UTF-8"{"name":"example message","description":"this is some description"}
20  * 
21  */
22 public class MyCustomMessageConverter extends MappingJackson2MessageConverter {
23
24   public MyCustomMessageConverter() {
25                 super(new MimeType("application", "json"));
26   }
27
28 }