Mule FTP 轮询停止,没有错误或警告
Mule FTP polling stops without error or warning
我遇到了 FTP Mule ESB 独立轮询的问题:
该应用程序 运行 几天没有出现问题,然后 FTP 轮询在没有发出警告或错误的情况下停止。
日志显示 FTP 轮询 activity 的迹象,直到它停止。之后什么都没有,但其他连接器仍然处于活动状态(主要是 SFTP 轮询)。我启用了DEBUG log on runtime,看看是否还有activity,对应的connector线程完全没有声音,好像停止或阻塞了。
最后,重启应用程序暂时解决了问题,但我试图了解为什么会出现这种情况,以避免再次遇到它。我怀疑 FTP 连接器线程停止或被阻止,阻止了进一步的轮询。
这可能是由我们用来防止在轮询后删除文件(覆盖 postProcess() 函数)的扩展 FtpMessageReceiver 引起的。但是查看此组件和基础 FTP 接收器和连接器的源代码,我看不出它是如何发生的。
知道为什么投票会突然停止而没有抛出错误吗?
这是当前的连接器配置:
<ftp:connector name="nonDeletingFtpConnector" doc:name="FTP"
pollingFrequency="${frequency}"
validateConnections="true">
<reconnect frequency="${frequency}" count="${count}"/>
<service-overrides messageReceiver="my.comp.NonDeletingFtpMessageReceiver" />
</ftp:connector>
以及对应的端点:
<ftp:inbound-endpoint host="${ftp.source.host}"
port="${ftp.source.port}"
path="${ftp.source.path}"
user="${ftp.source.login}"
responseTimeout="10000"
password="${ftp.source.password}"
connector-ref="archivingFtpConnector"
pollingFrequency="${ftp.default.polling.frequency}">
<file:filename-wildcard-filter pattern="*.zip"/>
</ftp:inbound-endpoint>
消息接收者代码:
public class NonDeletingFtpMessageReceiver extends FtpMessageReceiver {
public NonDeletingFtpMessageReceiver(Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint, long frequency) throws CreateException {
super(connector, flowConstruct, endpoint, frequency);
}
@Override
protected void postProcess(FTPClient client, FTPFile file, MuleMessage message) throws Exception {
//do nothing
}
}
如您所见,我们定义了一个 FtpMessageReceiver 以避免在轮询时删除文件(这是在流程中进一步完成的),但是查看代码我看不到如何跳过 super.postProcess()调用(负责删除文件)可能会导致问题。
我看过的FtpMessageReceiver源码:
https://github.com/mulesoft/mule/blob/mule-3.5.0/transports/ftp/src/main/java/org/mule/transport/ftp/FtpMessageReceiver.java
技术配置:
- Mule 独立版 3.5.0
- Ubuntu 14.04.2 LTS
- Java OpenJDK 运行时环境 (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1)
如有任何帮助,我们将不胜感激。提前致谢!
正如评论中所讨论的,该错误更多地与 Apache FTP 客户端相关,我创建了一个特定的 post .
这里是找到的解决方案:使用自定义 FtpConnectionFactory 正确配置客户端,超时值 > 0。这样挂起会因抛出超时异常而中断。
public class SafeFtpConnectionFactory extends FtpConnectionFactory{
//define a default timeout
public static int defaultTimeout = 60000;
public static synchronized int getDefaultTimeout() {
return defaultTimeout;
}
public static synchronized void setDefaultTimeout(int defaultTimeout) {
SafeFtpConnectionFactory.defaultTimeout = defaultTimeout;
}
public SafeFtpConnectionFactory(EndpointURI uri) {
super(uri);
}
@Override
protected FTPClient createFtpClient() {
FTPClient client = super.createFtpClient();
//Define the default timeout here, which will be used by the socket by default,
//instead of the 0 timeout hanging indefinitely
client.setDefaultTimeout(getDefaultTimeout());
return client;
}
}
然后将其连接到连接器:
<ftp:connector name="archivingFtpConnector" doc:name="FTP"
pollingFrequency="${frequency}"
validateConnections="true"
connectionFactoryClass="my.comp.SafeFtpConnectionFactory">
<reconnect frequency="${reconnection.frequency}" count="${reconnection.attempt}"/>
</ftp:connector>
如果另一个有任何显着变化,我会尝试更新这个答案。
我遇到了 FTP Mule ESB 独立轮询的问题: 该应用程序 运行 几天没有出现问题,然后 FTP 轮询在没有发出警告或错误的情况下停止。
日志显示 FTP 轮询 activity 的迹象,直到它停止。之后什么都没有,但其他连接器仍然处于活动状态(主要是 SFTP 轮询)。我启用了DEBUG log on runtime,看看是否还有activity,对应的connector线程完全没有声音,好像停止或阻塞了。
最后,重启应用程序暂时解决了问题,但我试图了解为什么会出现这种情况,以避免再次遇到它。我怀疑 FTP 连接器线程停止或被阻止,阻止了进一步的轮询。
这可能是由我们用来防止在轮询后删除文件(覆盖 postProcess() 函数)的扩展 FtpMessageReceiver 引起的。但是查看此组件和基础 FTP 接收器和连接器的源代码,我看不出它是如何发生的。
知道为什么投票会突然停止而没有抛出错误吗?
这是当前的连接器配置:
<ftp:connector name="nonDeletingFtpConnector" doc:name="FTP"
pollingFrequency="${frequency}"
validateConnections="true">
<reconnect frequency="${frequency}" count="${count}"/>
<service-overrides messageReceiver="my.comp.NonDeletingFtpMessageReceiver" />
</ftp:connector>
以及对应的端点:
<ftp:inbound-endpoint host="${ftp.source.host}"
port="${ftp.source.port}"
path="${ftp.source.path}"
user="${ftp.source.login}"
responseTimeout="10000"
password="${ftp.source.password}"
connector-ref="archivingFtpConnector"
pollingFrequency="${ftp.default.polling.frequency}">
<file:filename-wildcard-filter pattern="*.zip"/>
</ftp:inbound-endpoint>
消息接收者代码:
public class NonDeletingFtpMessageReceiver extends FtpMessageReceiver {
public NonDeletingFtpMessageReceiver(Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint, long frequency) throws CreateException {
super(connector, flowConstruct, endpoint, frequency);
}
@Override
protected void postProcess(FTPClient client, FTPFile file, MuleMessage message) throws Exception {
//do nothing
}
}
如您所见,我们定义了一个 FtpMessageReceiver 以避免在轮询时删除文件(这是在流程中进一步完成的),但是查看代码我看不到如何跳过 super.postProcess()调用(负责删除文件)可能会导致问题。
我看过的FtpMessageReceiver源码: https://github.com/mulesoft/mule/blob/mule-3.5.0/transports/ftp/src/main/java/org/mule/transport/ftp/FtpMessageReceiver.java
技术配置:
- Mule 独立版 3.5.0
- Ubuntu 14.04.2 LTS
- Java OpenJDK 运行时环境 (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1)
如有任何帮助,我们将不胜感激。提前致谢!
正如评论中所讨论的,该错误更多地与 Apache FTP 客户端相关,我创建了一个特定的 post
这里是找到的解决方案:使用自定义 FtpConnectionFactory 正确配置客户端,超时值 > 0。这样挂起会因抛出超时异常而中断。
public class SafeFtpConnectionFactory extends FtpConnectionFactory{
//define a default timeout
public static int defaultTimeout = 60000;
public static synchronized int getDefaultTimeout() {
return defaultTimeout;
}
public static synchronized void setDefaultTimeout(int defaultTimeout) {
SafeFtpConnectionFactory.defaultTimeout = defaultTimeout;
}
public SafeFtpConnectionFactory(EndpointURI uri) {
super(uri);
}
@Override
protected FTPClient createFtpClient() {
FTPClient client = super.createFtpClient();
//Define the default timeout here, which will be used by the socket by default,
//instead of the 0 timeout hanging indefinitely
client.setDefaultTimeout(getDefaultTimeout());
return client;
}
}
然后将其连接到连接器:
<ftp:connector name="archivingFtpConnector" doc:name="FTP"
pollingFrequency="${frequency}"
validateConnections="true"
connectionFactoryClass="my.comp.SafeFtpConnectionFactory">
<reconnect frequency="${reconnection.frequency}" count="${reconnection.attempt}"/>
</ftp:connector>
如果另一个有任何显着变化,我会尝试更新这个答案。