Spring integration Spring集成DSL动态入站通道
是否可以在运行时向spring integration dsl注册MessageSources 在我的例子中,我希望创建多个FileReadingMessageSources(基于UI的输入),然后将负载发送到特定的通道/jms路由(从元数据或用户输入读取)Spring integration Spring集成DSL动态入站通道,spring-integration,dsl,Spring Integration,Dsl,是否可以在运行时向spring integration dsl注册MessageSources 在我的例子中,我希望创建多个FileReadingMessageSources(基于UI的输入),然后将负载发送到特定的通道/jms路由(从元数据或用户输入读取) 另一个问题是,是否可以动态注册IntegrationFlows?这有点棘手,需要一些Spring基础设施知识,但确实可以: @Service public static class MyService { @Autowired
另一个问题是,是否可以动态注册IntegrationFlows?这有点棘手,需要一些Spring基础设施知识,但确实可以:
@Service
public static class MyService {
@Autowired
private AutowireCapableBeanFactory beanFactory;
@Autowired
@Qualifier("dynamicAdaptersResult")
PollableChannel dynamicAdaptersResult;
public void pollDirectories(File... directories) {
for (File directory : directories) {
StandardIntegrationFlow integrationFlow = IntegrationFlows
.from(s -> s.file(directory),
e -> e.poller(p -> p.fixedDelay(1000))
.id(directory.getName() + ".adapter"))
.transform(Transformers.fileToString(),
e -> e.id(directory.getName() + ".transformer"))
.channel(this.dynamicAdaptersResult)
.get();
this.beanFactory.initializeBean(integrationFlow, directory.getName());
this.beanFactory.getBean(directory.getName() + ".transformer", Lifecycle.class).start();
this.beanFactory.getBean(directory.getName() + ".adapter", Lifecycle.class).start();
}
}
}
请调查一下我的样品,告诉我您不清楚的地方。非常感谢,这正是我要找的