我正在通过spring集成开发一个多属性微服务。我正在从数据库中获取每个属性的登录凭据,如登录表。LOGIN表包含以下字段: LOGIN.username、LOGIN.pass和LOGIN.period(轮询者的句号)。如果我想让微服务基于LOGIN.period字段使用不同的轮询器配置,我该怎么做呢?
@Bean
public IntegrationFlow start() {
return IntegrationFlows
.from(() -> DAO.getLoginList()) // from a web service.
.split() // splits the each login credentials for each property.
.channel("X_CHANNEL") // subscribes to a channel todo business logic.
.get();
}是否可以实现一个组件,以基于数据库中的LOGIN.period值在不同的轮询器配置中创建工作流?
发布于 2020-09-30 01:21:35
基于Artem Bilan的回答,我已经实现了IntegrationFlowContext和IntegrationFlow实例;
@Autowired
IntegrationFlowContext flowContext;
@Bean
public void setFlowContext() {
List<Login> loginList = DAO.getLoginList(); // a web service
loginList.forEach(e -> {
IntegrationFlow flow = IntegrationFlows.from(() -> e, c -> c.poller(Pollers.fixedRate(e.getPeriod(), TimeUnit.SECONDS, 5)))
.channel("X_CHANNEL")
.get();
flowContext.registration(flow).register();
});
}https://stackoverflow.com/questions/64122660
复制相似问题