7919aa2f5fa43aef8a578aeec4fb84c9c5019728
[JavaForFun] /
1 package de.example.spring.kafka;
2
3 import org.springframework.cloud.stream.messaging.Source;
4 import org.springframework.context.annotation.Bean;
5 import org.springframework.context.annotation.Configuration;
6 import org.springframework.messaging.converter.MessageConverter;
7
8 import com.fasterxml.jackson.databind.ObjectMapper;
9
10 @Configuration
11 public class SenderConfig {
12
13   @Bean
14   public Sender sender(Source source) {
15     return new Sender(source);
16   }
17   
18   @Bean
19   public MessageConverter customMessageConverter(ObjectMapper objectMapper) {
20           MyCustomMessageConverter converter = new MyCustomMessageConverter();
21           converter.setSerializedPayloadClass(String.class);
22           if (objectMapper != null) {
23                   converter.setObjectMapper(objectMapper);
24           }
25           
26           return converter;
27   }
28
29 //  @Bean
30 //  public MessageConverter avroMessageConverter() throws IOException {
31 //      AvroSchemaMessageConverter converter = new AvroSchemaMessageConverter(MimeType.valueOf("avro/bytes"));
32 //      //converter.setSchemaLocation(new ClassPathResource("schemas/User.avro"));
33 //      return converter;
34 //  }
35 }