9157a7edf7303e554919a5abeb540c623734e83f
[JavaForFun] /
1 package de.example.spring.kafka;
2
3 import javax.inject.Inject;
4
5 import org.springframework.cloud.stream.annotation.EnableBinding;
6 import org.springframework.cloud.stream.messaging.Source;
7 import org.springframework.messaging.support.MessageBuilder;
8
9 @EnableBinding(Source.class)
10 public class Sender {
11   // Aquí podrías haber usado tu custom interface: InputOutputChannels :)
12   private final Source source;
13
14   @Inject
15   public Sender(Source source) {
16     this.source = source;
17   }
18
19   public void sendMessage(String message) {
20     source.output().send(MessageBuilder.withPayload(message).build());
21   }
22 }