5a9d1e2621019da12b2415a4e131ddd6999553f5
[JavaForFun] /
1 package de.example.spring.kafka;
2
3 import org.springframework.cloud.stream.schema.avro.AvroSchemaMessageConverter;
4 import org.springframework.context.annotation.Bean;
5 import org.springframework.context.annotation.Configuration;
6 import org.springframework.core.io.ClassPathResource;
7 import org.springframework.messaging.converter.MessageConverter;
8 import org.springframework.util.MimeType;
9
10 import java.io.IOException;
11
12 @Configuration
13 public class ReceiverConfig {
14
15   @Bean
16   public Receiver receiver() {
17     return new Receiver();
18   }
19
20
21   @Bean
22   public MessageConverter customMessageConverter() {
23     return new MyCustomMessageConverter();
24   }
25
26   @Bean
27   public MessageConverter avroMessageConverter() throws IOException {
28       AvroSchemaMessageConverter converter = new AvroSchemaMessageConverter(MimeType.valueOf("avro/bytes"));
29       //converter.setSchemaLocation(new ClassPathResource("schemas/User.avro"));
30       return converter;
31     }
32 }