Ali*_*lah 2 java spring esb spring-integration spring-batch
感谢您的关注,
我在我的项目中使用了 spring 集成,我想从多个具有不同地址的 ftp 服务器中检索许多输入文件,如下图所示:

如何inbound-adapter在我的项目中动态创建以从服务器轮询和检索文件?
如果您被允许在您的项目中使用非“通用”(GA) 版本的 3rd 方库(例如发布候选 (RC) 或里程碑 (M)),那么您可以使用5.0.0.M2Spring Integration版本。它是截至 2017 年 3 月 9 日的最新发布版本。
首先5.0,Spring Integration 包括Java DSL Runtime 流注册功能。它允许您定义集成流(包括入站适配器),就像您在标准 bean 中所做的那样,但它可以在任何运行时完成。
使用它只需以下 3 个步骤:
IntegrationFlowContext从 Spring 上下文中获取bean,例如通过自动装配: @Autowired
public MyClass(IntegrationFlowContext flowContext) {
this.flowContext = flowContext;
}
Run Code Online (Sandbox Code Playgroud)
IntegrationFlowRegistration registration = flowContext
.registration(IntegrationFlows // this method accepts IntegrationFlow instance
.from(s -> s.ftp(ftpSessionFactory())
.localFilter(localFileFilter())
//other actions
.get()) // standard end of DSL flow building process
.autoStartup(true) // not required but can be useful
.register(); // this makes the flow exist in the context
Run Code Online (Sandbox Code Playgroud)
IntegrationFlowContext使用您在上一步中获得的注册 ID 再次参考:// retrieve registration ID from the object created above
String dynamicFlowRegistrationId = registration.getId();
// the following will also gracefully stop all the processes within the flow
flowContext.remove(dynamicFlowRegistrationId);
Run Code Online (Sandbox Code Playgroud)
GitHub 上还有一个DynamicTcpClient 示例。
| 归档时间: |
|
| 查看次数: |
1803 次 |
| 最近记录: |