gpt4 book ai didi

java - 当调用 writeToDirectory 并且目标文件夹中存在同名文件时,Mule 入站端点会保留记录错误

转载 作者:行者123 更新时间:2023-12-01 09:09:14 25 4
gpt4 key购买 nike

我使用的是 mule 版本 3.5.0。在 Java Web 应用程序中。我使用 mule xml 配置并定义了一个 file:inbound-endpoint:

<file:inbound-endpoint path="${home.dir}/out" moveToDirectory="${home.dir}/out/hist" responseTimeout="10000" connector-ref="input"/>

连接器为:

<file:connector name="input" fileAge="10000" streaming="false" autoDelete="false">
<service-overrides messageFactory="org.mule.transport.file.FileMuleMessageFactory" />
</file:connector>

现在我遇到一个问题,当我想将一个文件移动到已经包含同名文件的目录时,mule 中会抛出错误并不断重复,生成 +1GB 日志文件:

[[hip].input.receiver.05] 18:33:55,234 [ERROR]        org.mule.exception.AbstractExceptionListener.logException(AbstractExceptionListener.java:307) - 
********************************************************************************
Message : Failed to move file "D:\hip\batch\taxiAsService\out\0.A.REQD.00000000000003.xml" to "D:\hip\batch\taxiAsService\out\hist\0.A.REQD.00000000000003.xml". The file might already exist.
Code : MULE_ERROR-11004
--------------------------------------------------------------------------------
Exception stack is:
1. Failed to move file "D:\hip\batch\taxiAsService\out\0.A.REQD.00000000000003.xml" to "D:\hip\batch\taxiAsService\out\hist\0.A.REQD.00000000000003.xml". The file might already exist. (org.mule.api.DefaultMuleException)
org.mule.transport.file.FileMessageReceiver:561 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/DefaultMuleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.DefaultMuleException: Failed to move file "D:\hip\batch\taxiAsService\out\0.A.REQD.00000000000003.xml" to "D:\hip\batch\taxiAsService\out\hist\0.A.REQD.00000000000003.xml". The file might already exist.
at org.mule.transport.file.FileMessageReceiver.moveAndDelete(FileMessageReceiver.java:561)
at org.mule.transport.file.FileMessageReceiver.access$100(FileMessageReceiver.java:58)
at org.mule.transport.file.FileMessageReceiver$2.process(FileMessageReceiver.java:433)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

[[hip].input.receiver.05] 18:33:55,240 [ERROR] org.mule.exception.AbstractExceptionListener.logException(AbstractExceptionListener.java:307) -
********************************************************************************
Message : Failed to move file "D:\hip\batch\taxiAsService\out\0.A.REQD.00000000000004.xml" to "D:\hip\batch\taxiAsService\out\hist\0.A.REQD.00000000000004.xml". The file might already exist.
Code : MULE_ERROR-11004
--------------------------------------------------------------------------------
Exception stack is:
1. Failed to move file "D:\hip\batch\taxiAsService\out\0.A.REQD.00000000000004.xml" to "D:\hip\batch\taxiAsService\out\hist\0.A.REQD.00000000000004.xml". The file might already exist. (org.mule.api.DefaultMuleException)
org.mule.transport.file.FileMessageReceiver:561 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/DefaultMuleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.DefaultMuleException: Failed to move file "D:\hip\batch\taxiAsService\out\0.A.REQD.00000000000004.xml" to "D:\hip\batch\taxiAsService\out\hist\0.A.REQD.00000000000004.xml". The file might already exist.
at org.mule.transport.file.FileMessageReceiver.moveAndDelete(FileMessageReceiver.java:561)
at org.mule.transport.file.FileMessageReceiver.access$100(FileMessageReceiver.java:58)
at org.mule.transport.file.FileMessageReceiver$2.process(FileMessageReceiver.java:433)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

[[hip].input.receiver.05] 18:33:55,242 [ERROR] org.mule.exception.AbstractExceptionListener.logException(AbstractExceptionListener.java:307) -
********************************************************************************
Message : Failed to move file "D:\hip\batch\taxiAsService\out\0.A.REQD.00000000000005.xml" to "D:\hip\batch\taxiAsService\out\hist\0.A.REQD.00000000000005.xml". The file might already exist.
Code : MULE_ERROR-11004
--------------------------------------------------------------------------------
Exception stack is:
1. Failed to move file "D:\hip\batch\taxiAsService\out\0.A.REQD.00000000000005.xml" to "D:\hip\batch\taxiAsService\out\hist\0.A.REQD.00000000000005.xml". The file might already exist. (org.mule.api.DefaultMuleException)
org.mule.transport.file.FileMessageReceiver:561 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/DefaultMuleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.DefaultMuleException: Failed to move file "D:\hip\batch\taxiAsService\out\0.A.REQD.00000000000005.xml" to "D:\hip\batch\taxiAsService\out\hist\0.A.REQD.00000000000005.xml". The file might already exist.
at org.mule.transport.file.FileMessageReceiver.moveAndDelete(FileMessageReceiver.java:561)
at org.mule.transport.file.FileMessageReceiver.access$100(FileMessageReceiver.java:58)
at org.mule.transport.file.FileMessageReceiver$2.process(FileMessageReceiver.java:433)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

有没有办法:

  • 限制日志记录?这样就只显示一个?
  • 我最终可以覆盖现有文件吗?

感谢您的阅读。

最佳答案

日志记录过多的问题是因为您将 autoDelete 属性设置为 false。因此,由于移动操作失败(并且源文件未被删除),因此流程正在递归轮询源文件。

解决方法是将 autoDelete 设置为 true 并使用 file:outbound-endpoint将源文件内容写入输出目录(而不是使用入站端点中的 moveToDirectory 属性)。这样您就可以自定义目标文件名以避免写入现有文件。

关于java - 当调用 writeToDirectory 并且目标文件夹中存在同名文件时,Mule 入站端点会保留记录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41024337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com