我在群集环境中使用下面的文件连接器
<file:connector
name="inputZip"
pollingFrequency="1000"
streaming="false"
autoDelete="true"
workDirectory="/home/sergio/compartilhado/temp">
<service-overrides messageFactory="org.mule.transport.file.FileMuleMessageFactory"/>
</file:connector>`
有时当群集的一个节点锁定文件时,另一个节点会尝试读取同一个文件并抛出异常
15:37:37,826 ERROR [org.mule.exception.DefaultSystemExceptionStrategy] ([sample].inputZip.receiver.01)
********************************************************************************
Message : File "teste.zip" does not exist or cannot be read
Code : MULE_ERROR-11007
--------------------------------------------------------------------------------
Exception stack is:
1. File "teste.zip" does not exist or cannot be read (org.mule.api.DefaultMuleException)
org.mule.transport.file.FileMessageReceiver:608 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/DefaultMuleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.DefaultMuleException: File "teste.zip" does not exist or cannot be read
at org.mule.transport.file.FileMessageReceiver.attemptFileLock(FileMessageReceiver.java:608)
at org.mule.transport.file.FileMessageReceiver.processFile(FileMessageReceiver.java:290)
at org.mule.transport.file.FileMessageReceiver.poll(FileMessageReceiver.java:238)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
我想记录另一条消息或在抛出之前处理此错误。有人可以帮我弄这个吗?提前谢谢
答案 0 :(得分:0)
我解决了扩展FileMessageReceiver类并覆盖下面方法的问题
public void processFile(File file) throws MuleException {
try {
super.processFile(file);
} catch (Exception e) {
logger.info("Fail to read file " + e);
}
}
在我的连接器中,我已在标签服务中添加 - 覆盖属性messageReceiver =“br.com.unimed.wsd.tiss.mule.batch.FileSampleMessageFactory”