如何在 Anypoint Studio(MuleSoft) 中设置排程和合并文件

How to set schedule and merge file in Anypoint Studio(MuleSoft)

我想使用 MuleSoft Anypoint Studio 设置时间表和合并文件。

示例: 文件名(文件夹名)input/a.txt包括

1, 2, 3

另一个文件名为(文件夹名称)output/b.txt其中包括

4, 5, 6

我想将 a.txt 文件的 内容合并到 b.txt 第二天早上 0 点 文件如下:

b.txt

4, 5, 6
1, 2, 3

我想用 Schedule/Write 函数解决这个问题,但我做不到。

谁能帮忙解决这个问题?

使用Scheduler component, and the File connector's read and write operations you can achieve that. I wrote an example below. For the output file you have to set the write modeAPPEND是正确的,不会覆盖已有的内容。请注意,要使其正常工作,输入文件需要在记录末尾有一个行尾。

请注意 Anypoint Studio 是 IDE。它不会实现任何东西,但是您可以使用它来开发一个 Mule 应用程序来实现您的要求。该应用程序将由 Mule Runtime 在 Studio 或其他环境中执行。

<file:config name="File_Config" doc:name="File Config" />
<flow name="test-file-appendFlow" >
    <scheduler doc:name="Scheduler" >
        <scheduling-strategy >
            <fixed-frequency frequency="1" timeUnit="DAYS"/>
        </scheduling-strategy>
    </scheduler>
    <file:read doc:name="Read" config-ref="File_Config" path="/tmp/input/a.txt"/>
    <file:write doc:name="Write" config-ref="File_Config" path="/tmp/output/b.txt" mode="APPEND"/>
</flow>