简单重命名时删除MuleStudio文件

简单重命名时删除MuleStudio文件,mule,mule-studio,Mule,Mule Studio,在MuleStudio中,一个简单的重命名脚本会在一段时间后删除文件。以下是脚本的外观: <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/c

在MuleStudio中,一个简单的重命名脚本会在一段时间后删除文件。以下是脚本的外观:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.4.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd">
    <flow name="ftp_ping_pong_testFlow1" doc:name="ftp_ping_pong_testFlow1" initialState="started" processingStrategy="queued-asynchronous">
        <file:inbound-endpoint path="C:\ftp_ping_pong_test\src\test\in\" responseTimeout="10000" doc:name="File" fileAge="1000" pollingFrequency="1200">
            <file:filename-regex-filter pattern="^.*\.csv$" caseSensitive="true"/>
        </file:inbound-endpoint>
        <file:outbound-endpoint path="C:\ftp_ping_pong_test\src\test\in\" outputPattern="#[message.inboundProperties['originalFilename']].temp" responseTimeout="10000" doc:name="File"/>
    </flow>
    <flow name="ftp_ping_pong_testFlow2" doc:name="ftp_ping_pong_testFlow2">
        <file:inbound-endpoint path="C:\ftp_ping_pong_test\src\test\in\" responseTimeout="10000" doc:name="File" fileAge="1000" pollingFrequency="1200">
            <file:filename-regex-filter pattern="^.*\.temp$" caseSensitive="true"/>
        </file:inbound-endpoint>
        <file:outbound-endpoint path="C:\ftp_ping_pong_test\src\test\in\" outputPattern="#[message.inboundProperties['originalFilename'].replace('.temp','')]" responseTimeout="10000" doc:name="File"/>
    </flow>
</mule> 
我已经因为这个问题失去了一周的时间,因此非常感谢您的帮助:)

更新: 我创建了两个不同的应用程序。这是:

<?xml version="1.0" encoding="UTF-8"?>

<mule Links removed by Stackoverflow">
    <file:connector name="File_Connector_CSV"    autoDelete="true" streaming="false" validateConnections="true" doc:name="File" readFromDirectory="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\in" writeToDirectory="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\out"/>
    <flow name="ftp_ping_pong_testFlow1" doc:name="ftp_ping_pong_testFlow1" initialState="started" processingStrategy="synchronous">
        <file:inbound-endpoint path="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\in\" responseTimeout="10000" doc:name="File" fileAge="1000" pollingFrequency="1200" connector-ref="File_Connector_CSV"  >
            <file:filename-regex-filter pattern="^.*\.csv$" caseSensitive="true"/>
        </file:inbound-endpoint>
        <file:outbound-endpoint  outputPattern="#[message.inboundProperties['originalFilename']].temp" responseTimeout="10000" doc:name="File" path="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\out"/>
    </flow>
</mule>
在这些日志条目之后,该文件就消失了,在日志中没有任何进一步的跟踪。 我观察到,即使在MuleStudio中有一个为文件年龄定义的默认值,该值也不会在XML文件中表示,这就是Player2没有定义文件年龄的原因

我可以想象一种可能的情况: -Player1,读取csv文件并创建临时文件。播放器2读取temp并写回csv。Player1删除csv,认为它仍然是原始文件。在这种情况下,Player1太慢,让Player2干预,如果Player2没有文件期限,则可能发生这种情况。-我必须用相应的文件期限值设置重新测试,但这并不能解释为什么这种情况很少发生

谢谢, Gabor更新 我知道你的感受。添加文件连接器时,取消选中常规选项卡中的自动删除


经过无数次的实验,我终于找到了问题所在

当mule启动应用程序时,似乎只会检查一次文件龄属性,而不是单独检查每个流(可能这是正常的,但我没有预料到这种行为)。即使使用不同的流,文件期属性是什么也不重要,只要它小于Mule的标准启动时间(说是5000毫秒,但实际上是50000毫秒-有人在某处加了一个零)

发生了什么,Player1和Player2总是试图同时读取、复制和删除所有文件。这只是一个时间问题,直到我上面描述的情景发生

该解决方案现在运行良好,通过创建两个具有足够大的文件年龄的独立应用程序(请注意,在MuleStudio中定义文件年龄是不够的,它还必须在XML中!)


希望它能为某人节省时间,并感谢所有的好意

大家好,欢迎来到Stack Overflow!到目前为止,您尝试了什么?您好,到目前为止,我尝试了以下几种:轮询(500100015003000)和文件年龄(4006009001000150016004500)的不同设置及其组合;不同的端点:文件、FTP及其组合;将它们放在不同的流程、项目中;在MuleStudio中部署它们,独立于不同的操作系统(win7、Ubuntu)及其组合(Ubuntu上的FTP、win7上的Mule);不同的处理策略:同步、排队异步;有maven和没有maven;还应该测试什么?我选中了,但是在界面上,没有“取消选中”这个选项的选项。对于autoDelete,如果有帮助,则该选项无效。以下是版本信息:*Mule ESB和集成平台**版本:3.4.0内部版本:c8afb471**MuleSoft,Inc.*有关更多信息,请转到*服务器已启动:18/12/13 10:19*JDK:1.7.0_45(混合模式)*操作系统:Windows 7-Service Pack 1(6.1,x86)*主机:用户PC(192.168.0.202)不,您不必将其写入xml。我忘了说boud端点中的文件。它不会与Outbound.Mule Studio-Tooling for Mule ESB版本:3.5.0构建Id:201312091746一起出现
<?xml version="1.0" encoding="UTF-8"?>

<mule Links removed by Stackoverflow">
    <file:connector name="File_Connector_CSV"    autoDelete="true" streaming="false" validateConnections="true" doc:name="File" readFromDirectory="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\in" writeToDirectory="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\out"/>
    <flow name="ftp_ping_pong_testFlow1" doc:name="ftp_ping_pong_testFlow1" initialState="started" processingStrategy="synchronous">
        <file:inbound-endpoint path="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\in\" responseTimeout="10000" doc:name="File" fileAge="1000" pollingFrequency="1200" connector-ref="File_Connector_CSV"  >
            <file:filename-regex-filter pattern="^.*\.csv$" caseSensitive="true"/>
        </file:inbound-endpoint>
        <file:outbound-endpoint  outputPattern="#[message.inboundProperties['originalFilename']].temp" responseTimeout="10000" doc:name="File" path="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\out"/>
    </flow>
</mule>
<?xml version="1.0" encoding="UTF-8"?>

<mule links removed by Stackoverflow">
    <file:connector name="File" writeToDirectory="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\in" readFromDirectory="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\out" autoDelete="true" streaming="false" validateConnections="true" doc:name="File"/>
    <flow name="ftp_ping_pong_player2Flow1" doc:name="ftp_ping_pong_player2Flow1">
        <file:inbound-endpoint path="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\out" responseTimeout="10000" doc:name="File" connector-ref="File">
            <file:filename-regex-filter pattern="^.*\.temp$" caseSensitive="true"/>
        </file:inbound-endpoint>
        <file:outbound-endpoint path="C:\Users\gabor.bodo\MuleStudio\workspace\ftp_ping_pong_test\src\test\in\" outputPattern="#[message.inboundProperties['originalFilename'].replace('.temp','')]" responseTimeout="10000" doc:name="File" connector-ref="File"/>
    </flow>
</mule>
    INFO  2013-12-20 17:58:13,843 [[ping_pong_player1].File_Connector_CSV.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\ftp_ping_pong_test\src\test\in\09.csv
    INFO  2013-12-20 17:58:14,519 [[ping_pong_player1].File_Connector_CSV.receiver.01] org.mule.transport.file.FileConnector: Writing file to: C:\ftp_ping_pong_test\src\test\out\09.csv.temp
    INFO  2013-12-20 17:58:14,812 [[ping_pong_player2].File.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\ftp_ping_pong_test\src\test\out\09.csv.temp
    INFO  2013-12-20 17:58:15,437 [[ping_pong_player2].File.dispatcher.402] org.mule.transport.file.FileConnector: Writing file to: C:\ftp_ping_pong_test\src\test\in\09.csv