我试图在MuleRequester的帮助下移动文件。对于大文件(300MB> x),有时while流阻塞,我总是收到以下错误消息。
文件一直被java.exe进程锁定。
使用小文件没有问题。
该文件保留在文件夹" C:\ itm \ main \ datafeeds \ backup"和" C:\ itm \ main \ datafeeds \ process \"是空的。
我不知道如何解决这个问题。
错误消息:
Message : Failed to move file "C:\itm\main\datafeeds\backup\my_file.xml" to "C:\itm\main\datafeeds\process\my_file.xml". The file might already exist.
Payload : [{numOfRecords=0}]
Payload Type : java.util.LinkedList
Endpoint : DefaultInboundEndpoint{endpointUri=file:///C:/itm/main/datafeeds/backup/?autoDelete=true, connector=FileConnector
{
name=File
lifecycle=start
this=300a38e7
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[file]
serviceOverrides=<none>
}
, name='endpoint..C.itm.main.datafeeds.backup', mep=ONE_WAY, properties={autoDelete=true}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}
Timeout : 1000
Element : /poller_product_parse_aff_file/processors/0/0/1 @ product_2_parse_aff_file_to_db
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.DefaultMuleException: Failed to move file "C:\itm\main\datafeeds\backup\my_file.xml" to "C:\itm\main\datafeeds\process\my_file.xml". The file might already exist.
at org.mule.transport.file.FileMessageRequester.moveOrDelete(FileMessageRequester.java:222)
at org.mule.transport.file.FileMessageRequester.doRequest(FileMessageRequester.java:188)
at org.mule.transport.AbstractMessageRequester.request(AbstractMessageRequester.java:94)
at org.mule.transport.AbstractConnector.request(AbstractConnector.java:2259)
at org.mule.endpoint.DefaultInboundEndpoint.request(DefaultInboundEndpoint.java:80)
at org.mule.client.DefaultLocalMuleClient.request(DefaultLocalMuleClient.java:184)
at org.mule.module.MuleRequesterModule.request(MuleRequesterModule.java:64)
...
&#13;
骡子请求者cfg:
<mulerequester:request resource="${file.RequesterUrl}" timeout="1000" doc:name="Mule Requester" />
&#13;
环境:
操作系统:Windows Server 2012R2
JRE:v1.7
骡子请求者:v1.5
Mule Anypoint Studio:Mule Server 3.8.0 CE
答案 0 :(得分:0)
使用这样的大文件时,问题主要出现在java的内存中。尝试增加可用(最大)java堆大小。
答案 1 :(得分:0)
感谢您的回答! 我过去曾遇到过这样的堆问题,我想这不是问题所在,因为堆问题会引发特定的错误信息。
我的vm参数是:
-Xms2048m
-Xmx4096m
-XX:MaxPermSize=2048m
&#13;
答案 2 :(得分:0)
我认为您将同一文件再次复制到同一位置。
org.mule.api.DefaultMuleException: Failed to move file "C:\itm\main\datafeeds\backup\my_file.xml" to "C:\itm\main\datafeeds\process\my_file.xml". The file might already exist.
您可以发布完整的xml配置以进一步提供帮助。
答案 3 :(得分:0)
其他替代方法是使用文件出站并将有效负载写回输出文件。对于只是移动文件,可能有许多其他选择,如批处理/ shell脚本等。
答案 4 :(得分:0)
感谢您的帮助!
这是整个流程:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:mulerequester="http://www.mulesoft.org/schema/mule/mulerequester" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
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"
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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/mulerequester http://www.mulesoft.org/schema/mule/mulerequester/current/mule-mulerequester.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">
<file:connector name="File" autoDelete="true" streaming="false" validateConnections="false" doc:name="File" outputAppend="true" moveToDirectory="${file.workingDir}" />
<flow name="poller_product_parse_aff_file" processingStrategy="synchronous">
<poll doc:name="Poll">
<fixed-frequency-scheduler frequency="15" timeUnit="SECONDS"/>
<db:select config-ref="MYSQL_GENERIC_CFG" doc:name="Database">
<db:parameterized-query><![CDATA[SELECT COUNT(*) AS numOfRecords FROM mule_product]]></db:parameterized-query>
</db:select>
</poll>
<choice doc:name="Choice">
<when expression="#[payload.get(0).numOfRecords < 1000]">
<logger message="#[System.getProperty('line.separator')] ############################ Database is free, so start parsing next xml file ###########################:: #[flowVars.fileRequesterUrl]" level="TRACE" doc:name="Logger"/>
<mulerequester:request resource="${file.RequesterUrl}" timeout="30000" doc:name="Mule Requester"/>
<choice doc:name="Choice">
<when expression="#[payload != null && payload.size()>0]">
<logger message="#[System.getProperty('line.separator')] +++ DB is free and file was found" level="TRACE" doc:name="Logger"/>
<flow-ref name="product_parse_aff_file_to_dbFlow" doc:name="product_parse_aff_file_to_dbFlow"/>
</when>
<otherwise>
<logger message="#[System.getProperty('line.separator')] --- File not found or filesize is zero: #[payload]" level="TRACE" doc:name="Logger"/>
</otherwise>
</choice>
</when>
<when expression="">
<logger message="::::::::::::::: start of parsing the files:no fo records in db :::::>#[payload.get(0).numOfRecords]" level="TRACE" doc:name="Logger"/>
</when>
<otherwise>
<logger message="::::::::::file processing not started as the condition is not met i.e SELECT COUNT(*) AS numOfRecords FROM mule_product >1000" level="TRACE" doc:name="Logger"/>
</otherwise>
</choice>
</flow>
....
</mule>
&#13;