Spring integration 春云流。作为单个事件的事件源列表
我使用springcloudstream来获取事件。我的问题是,我不想将事件列表发送到Source.OUTPUT,而是发送单个事件。配置单一事件来源的最佳实践是什么?我提出了以下解决方案。还有别的办法吗Spring integration 春云流。作为单个事件的事件源列表,spring-integration,spring-cloud-stream,Spring Integration,Spring Cloud Stream,我使用springcloudstream来获取事件。我的问题是,我不想将事件列表发送到Source.OUTPUT,而是发送单个事件。配置单一事件来源的最佳实践是什么?我提出了以下解决方案。还有别的办法吗 @EnableBinding(Source.class) public class SharedMailboxesPoller { @InboundChannelAdapter(channel = "splitterChannel", poller = @Poller(fixedDelay
@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;
}
}
是的,DSL将更加紧凑
IntegrationFlows.from(..., e -> e.poller(...))
.split()
.channel(Source.OUTPUT);
或者,您可以简单地从入站适配器返回单个事件;只需在轮询器中将maxMessagesPerPoll设置为一个大的数字,适配器就会在每次轮询时被多次调用,直到它返回null。这很好;你为什么要质疑它?是的,但它很麻烦。我想还有另一种方法,更紧凑。也许是JavaDSL?