【发布时间】:2019-12-27 20:26:31
【问题描述】:
我编写了我的第一个 spring 集成应用程序,它从 spring RSS 读取数据并将其记录到控制台:
@Configuration
@EnableIntegration
@IntegrationComponentScan
public class DslConfig {
@Bean
public IntegrationFlow feedFlow() throws MalformedURLException {
return IntegrationFlows.from(inBoundFeedDataAdapter(), configurer -> configurer.poller(Pollers.fixedDelay(1000)))
.channel(newsChannel())
.transform(source -> {
SyndEntry e = ((SyndEntry) source);
return e.getTitle() + " " + e.getLink();
})
.handle(messageHandler())
.get();
}
@Bean
public FeedEntryMessageSourceSpec inBoundFeedDataAdapter() throws MalformedURLException {
return Feed.inboundAdapter(new URL("https://spring.io/blog.atom"), "some_key");
}
@Bean
public MessageChannel newsChannel() {
return new DirectChannel();
}
@Bean
public MessageHandler messageHandler() {
return System.out::println;
}
}
但我不知道如何添加一个额外的处理程序来将结果写入文件。
我怎样才能实现它?
其他问题:
元数据键是什么意思?
【问题讨论】:
标签: java spring spring-boot spring-integration spring-integration-dsl