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