我有一个Spring集成流程如下。弹簧集成 - 入站文件端点。如何正确处理文件。
<int-file:inbound-channel-adapter id="filesIn"
directory="file:${incomingDir}"
filename-pattern="*.txt"
prevent-duplicates="true">
<int:poller id="poller" fixed-delay="5000"/>
</int-file:inbound-channel-adapter>
<int:splitter input-channel="filesIn"
ref="filesSplitterService"
method="splitFilesToReportContent"
output-channel="reportProcessIn"
/>
<int:channel id="reportProcessIn"/>
<int:chain input-channel="reportProcessIn" output-channel="reportProcessOut">
<int:service-activator ref="reportProcessorService" method="readReportMetaData" />
<int:service-activator ref="reportProcessorService" method="saveReportFileInFileSystem" />
<int:service-activator ref="reportProcessorService" method="saveReportMetaDataInDB" />
</int:chain>
<int:channel id="reportProcessOut"/>
<bean id="filesSplitterService" class="com.app.integration.FilesSplitter"/>
<bean id="reportProcessorService" class="com.app.reporting.integration.ReportProcessor"/>
传入文件是由一个服务劈裂,使ReportContent的名单。
然后服务链采取ReportContent的每个元素的作品对他们从文件的内容(如报告编号,报告类型)read_report_meta_data,保存内容字符串报告在适当的目录中的文件,并保存报表元数据库中的数据。流程运行良好,除了似乎有一个松散的结局。
我收到以下异常。
org.springframework.integration.MessageDeliveryException:调度 没有订户
我不需要聚集分裂元素。在将元数据保存到数据库后,就我所关注的流程完成。
但是我想在使用它之后将原始文件,即我分割成报告文件的主文件移动到其他目录。我怎么能把这个逻辑结合起来?文件:出站渠道似乎是这样做的方式,但我不明白如何。
有没有办法避免saveReportFileInSystem和saveReportMetaDataInDB操作基于readReportMetaData操作中读取的一些元数据。
为了方便起见,我在下面给出了我的服务类的结构。
类:FilesSplitter
public List<ReportContent> splitFilesToReportContent(File file){
}
类:ReportProcessor
public ReportContent readReportMetaData(ReportContent reportContent) {
}
public ReportContent saveReportFileInFileSystem(ReportContent reportContent) {
}
public ReportContent saveReportMetaDataInDB(ReportContent reportContent) {
}
有一点要注意的是,我不使用邮件头。我还没有觉得有必要使用,但我可以使用。我对Spring集成很陌生,所以任何改善这种流程的建议都会有所帮助。
嗯,我不能投票回答两次:-) –