Spring Integration - Log time taken for whole file processing

我们两清 提交于 2021-02-11 05:01:57

问题


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?

Any help is appreciated.

<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>

Regards Karthik


回答1:


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.

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.



来源:https://stackoverflow.com/questions/32213467/spring-integration-log-time-taken-for-whole-file-processing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!