Spring Integration-记录整个文件所花费的时间 [英] Spring Integration - Log time taken for whole file processing

查看:75
本文介绍了Spring Integration-记录整个文件所花费的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用File Inbound,Splitter,Transformer和File Outbound适配器将大文件拆分为小块的方案.我想知道处理文件从读取到拆分再写回需要多长时间.如何实现此功能?

I have a scenario to split a large files to small chunks using File Inbound, Splitter, Transformer and File Outbound adapter. I would like to know how long it took to process the file starting from read to split to write back. How do I achieve this functionality?

感谢您的帮助.

<file:inbound-channel-adapter directory="/Documents" filename-pattern="test.txt" channel="inputFiles">
    <int:poller fixed-delay="0"/>
</file:inbound-channel-adapter>

<int:channel id="inputFiles">
    <int:dispatcher task-executor="executor"/>
</int:channel>

<int:splitter
        input-channel="inputFiles"
        output-channel="output" ref="multiTaskFileSplitter" method="splitMessage" apply-sequence="true">
</int:splitter>


<int:channel id="output">
    <int:dispatcher task-executor="executor1"/></int:channel>

<file:outbound-channel-adapter mode="APPEND" channel="output" auto-create-directory="true" delete-source-files="true" directory="/splitter" filename-generator="fileNameGenerator">
</file:outbound-channel-adapter>

问候卡尔提克

推荐答案

您可以在流程开始时通过 ChannelInterceptor MessageHeaders 修改来做到这一点-添加一些 currentTime 标头.并计算流结束时所花费的时间.也可以使用相同的 ChannelInterceptor 完成.

You can do that with ChannelInterceptor and MessageHeaders modification in the beginning of the flow - adding some currentTime header. And calculation the spent time in the end of flow. It can be done with the same ChannelInterceptor, too.

从Spring Integration 4.2开始,我们现在有了 AbstractMessageSourceAdvice ,可以将其应用于< int文件的< poller> 上:用于相同的 currentTime 标头添加逻辑.

Starting with the Spring Integration 4.2 we have now AbstractMessageSourceAdvice which can be applied to the <poller>'s of the <int-file:inbound-channel-adapter> for the same currentTime header addition logic.

这篇关于Spring Integration-记录整个文件所花费的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆