0
我想知道是否可以调用流源而不是轮询。 我的来源是这样的(行不通):Spring Cloud Stream - 编程式发布
@SpringBootApplication
@RestController
@EnableBinding(Source.class)
public class ServiceApplication {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
public static void main(String[] args) {
SpringApplication.run(ServiceApplication.class, args);
}
@Autowired
private PersonsRepository dao;
@GetMapping("/send")
public String sendMessage() {
this.sendVoter("foo");
return "VOTER SENT";
}
@SentTo(Source.OUTPUT)
private Person sendVoter(String name) {
logger.warn("Sending...");
return dao.findByFirstname(name);
}
}
为了使它开始,我不得不代码:
@SpringBootApplication
@RestController
@EnableBinding(Source.class)
public class ServiceApplication {
...
@GetMapping("/send")
public String sendMessage() {
this.sendVoter();
return "VOTER SENT";
}
@InboundChannelAdapter(Source.OUTPUT)
private Person sendVoter() {
logger.warn("Sending...");
return dao.findByFirstname("foo");
}
}
但来源开始的时候了。它不是以编程方式触发的。 我是否必须使用ApplicationEventPublisher,还是仅针对Spring Cloud Bus应用程序?我无法想到的任何其他提示? 感谢任何轻
权。非常感谢你。 –
@Autowired源代码; 。source.output()发送(MessageBuilder.withPayload(MSG).build()); –
那么,SendTo注释呢?它是什么,只有处理器? –