Recent Posts
Archives

Posts Tagged ‘component’

PostHeaderIcon Mule: File transport reads many times the same file

Case
With Mule ESB 2.2.1, I use a classic <file:inbound-endpoint>:

[xml]<file:inbound-endpoint path="${fromPath}"
pollingFrequency="3000" fileAge="5000"
moveToDirectory="${moveToDirectory}"
synchronous="true"
>
<transformers>
<transformer ref="mySimpleCSVParser">
</transformers>
</file:inbound-endpoint>
[/xml]

When I launch the Mule with no component (entreprise layer), everything is OK: the file is loaded, parsed and moved. But when I introduce a minimal component, which does nothing, then the file is read many times. Mule ESB seems to loop indefinitely, reading the file many times, without deleting it from the directory.

[java]INFO  2010-03-04 15:47:18,291 [connector.file.0.receiver.6] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\temp\myFile.txt[/java]

Fix

Firstly I tried to increase the pollingFrequency attribute, assuming that the file had not yet been completely parsed when another cycle of “load-parse-move”. But it did not fix the issue.

Indeed, the problem was not related to the component layer, but to the parser itself. To fix the issue, you have to ensure the InputStream is properly closed in your Transformer layer:

[java]try
{
inputStream.close();
return  answer;
} catch (IOException e)
{
throw new TransformerException((Message)null, e);
}[/java]