【发布时间】:2018-07-04 13:30:06
【问题描述】:
我使用 Spring Cloud Stream 来获取事件。我的问题是我不想发送到 Source.OUTPUT 事件列表,而是单个事件。配置采购单一事件的最佳实践是什么?我想出了以下解决方案。还有其他方法吗?
@EnableBinding(Source.class)
public class SharedMailboxesPoller {
@InboundChannelAdapter(channel = "splitterChannel", poller = @Poller(fixedDelay = "30000"))
public List<NewMailEvent> pollNewMails() {
...
if (!newMailEvents.isEmpty()) {
return newMailEvents;
} else {
//if no events, it will send nothing
return null;
}
}
@Bean
public MessageChannel splitterChannel() {
return MessageChannels.direct().get();
}
@Splitter(inputChannel = "splitterChannel", outputChannel = Source.OUTPUT)
public List<NewMailEvent> newMailEventsSplitter(List<NewMailEvent> newEvents) {
return newEvents;
}
}
【问题讨论】:
-
这很好;你为什么质疑它?
-
是的,但是很麻烦。我认为还有另一种方式,更紧凑。也许用 java dsl?
标签: spring-integration spring-cloud-stream