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