【发布时间】:2018-03-05 09:26:06
【问题描述】:
@SpringBootApplication
@EnableBinding(MyProcessor.class)
public class MultipleOutputsServiceApplication {
public static void main(String[] args) {
SpringApplication.run(MultipleOutputsServiceApplication.class, args);
}
@Autowired
private MyProcessor processor;
@StreamListener(MyProcessor.INPUT)
public void routeValues(Integer val) {
if (val < 10) {
processor.anOutput()
.send(message(val));
} else {
processor.anotherOutput()
.send(message(val));
}
}
private static final <T> Message<T> message(T val) {
return MessageBuilder.withPayload(val)
.build();
}
}
MyProcessor 接口:
public interface MyProcessor {
String INPUT = "myInput";
@Input
SubscribableChannel myInput();
@Output("myOutput")
MessageChannel anOutput();
@Output
MessageChannel anotherOutput();
}
我的问题:
为什么MultipleOutputsServiceApplication类中的方法routeValues被注释为MyProcessor.INPUT而不是MyProcessor.myOutput(在将这个成员添加到MyProcessor接口之后)?
From the docs, INPUT 用于获取数据,OUTPUT 用于发送数据。为什么示例相反,如果我将其反转,则没有任何效果?
【问题讨论】:
标签: java spring spring-cloud spring-cloud-stream