我已经编写了代理服务,并部署在WSO2 ESB 5上,以通过http接收一些文件内容,并使用vfs传输将该内容传输到ftp服务器。当我正确指定连接参数但在连接字符串上指定错误以模拟停机服务器时,该服务将按预期工作,因此无法使用[1]中指定的参数来控制VFS传输的行为。我要寻找的是缩短VFS中发生的错误与Axis捕获的故障异常之间的延迟。

正如您将在下面看到的,我指定了0次重试和两次重试之间的等待时间,但是VFSTransportSender类似乎无法以某种方式读取这些值,因为它始终执行相同的重试次数,并且等待相同的秒数每次执行时,我也会更改值并放入其他值,但结果始终相同,除了原始请求外,服务器始终会在Axis能够接收一些相关信息之前,除原始请求外,相互重试3次,每次间隔30秒错误。

这是我的代理服务,可以正常工作:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ftpProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="https,http">
   <target>
  <inSequence>
     <log level="full"/>
     <property expression="json-eval($.key)" name="file_name"/>
     <property name="OUT_ONLY" value="true"/>
     <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
     <property name="HTTP_SC" scope="axis2" value="200"/>
     <property expression="fn:concat(get-property('file_name'), '.json')"
               name="transport.vfs.ReplyFileName"
               scope="transport"/>
     <property name="OUT_ONLY" value="true"/>
  </inSequence>
  <endpoint name="ftp_endpoint">
     <address uri="vfs:ftp://jairof_ftp:passftp@localhost:21">
        <timeout>
           <duration>2000</duration>
           <responseAction>fault</responseAction>
        </timeout>
        <suspendOnFailure>
           <errorCodes>-1</errorCodes>
           <progressionFactor>1.0</progressionFactor>
        </suspendOnFailure>
        <markForSuspension>
           <errorCodes>-1</errorCodes>
        </markForSuspension>
     </address>
  </endpoint>
   </target>
   <parameter name="transport.vfs.ReconnectTimeout">0</parameter>
   <parameter name="transport.vfs.MaxRetryCount">0</parameter>
   <description/>
</proxy>


当我想模拟服务器无法访问时,我只需修改地址URI并将其放置在用户不正确的地方:

<address uri="vfs:ftp://ja8irof_ftp:passftp@localhost:21">

我也曾尝试在调用端点之前将transport.vfs参数设置为属性,但结果完全相同

在这里,您可以检查日志文件的一部分,在其中我剪切了堆栈跟踪的某些部分以使发布更简单:

[2016-10-29 12:23:01,134] ERROR - VFSTransportSender cannot resolve replyFile
org.apache.commons.vfs2.FileSystemException: Could not connect to FTP server on "localhost".
... (the rest of stack trace)
...
Caused by: org.apache.commons.vfs2.FileSystemException: Could not login to FTP server on "localhost" as user "ja8irof_ftp".
at org.apache.commons.vfs2.provider.ftp.FtpClientFactory.createConnection(FtpClientFactory.java:210)
... 29 more

[2016-10-29 12:23:34,223] ERROR - VFSTransportSender cannot resolve replyFile
org.apache.commons.vfs2.FileSystemException: Could not connect to FTP server on "localhost".
... (the rest of stack trace)
...
Caused by: org.apache.commons.vfs2.FileSystemException: Could not login to FTP server on "localhost" as user "ja8irof_ftp".
at org.apache.commons.vfs2.provider.ftp.FtpClientFactory.createConnection(FtpClientFactory.java:210)
... 29 more

[2016-10-29 12:24:07,842] ERROR - VFSTransportSender cannot resolve replyFile
org.apache.commons.vfs2.FileSystemException: Could not connect to FTP server on "localhost".
... (the rest of stack trace)
...
Caused by: org.apache.commons.vfs2.FileSystemException: Could not login to FTP server on "localhost" as user "ja8irof_ftp".
at org.apache.commons.vfs2.provider.ftp.FtpClientFactory.createConnection(FtpClientFactory.java:210)
... 29 more

[2016-10-29 12:24:07,844] ERROR - VFSTransportSender cannot resolve replyFile repeatedly: Could not connect to FTP server on "localhost".
org.apache.commons.vfs2.FileSystemException: Could not connect to FTP server on "localhost".
... (the rest of stack trace)
...
Caused by: org.apache.commons.vfs2.FileSystemException: Could not login to FTP server on "localhost" as user "ja8irof_ftp".
at org.apache.commons.vfs2.provider.ftp.FtpClientFactory.createConnection(FtpClientFactory.java:210)
... 29 more

[2016-10-29 12:24:07,846] ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.AxisFault: cannot resolve replyFile repeatedly: Could not connect to FTP server on "localhost".
... (the rest of stack trace)
...
Caused by: org.apache.commons.vfs2.FileSystemException: Could not connect to FTP server on "localhost".
at org.apache.commons.vfs2.provider.ftp.FtpClientFactory.createConnection(FtpClientFactory.java:275)
at org.apache.commons.vfs2.provider.ftp.FTPClientWrapper.createClient(FTPClientWrapper.java:100)
at org.apache.commons.vfs2.provider.ftp.FTPClientWrapper.getFtpClient(FTPClientWrapper.java:134)
at org.apache.commons.vfs2.provider.ftp.FTPClientWrapper.<init>(FTPClientWrapper.java:59)
at org.apache.commons.vfs2.provider.ftp.FtpFileProvider.doCreateFileSystem(FtpFileProvider.java:128)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.getFileSystem(AbstractOriginatingFileProvider.java:155)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:119)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:88)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:738)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:626)
at org.apache.synapse.transport.vfs.VFSTransportSender.writeFile(VFSTransportSender.java:233)
... 19 more
Caused by: org.apache.commons.vfs2.FileSystemException: Could not login to FTP server on "localhost" as user "ja8irof_ftp".
at org.apache.commons.vfs2.provider.ftp.FtpClientFactory.createConnection(FtpClientFactory.java:210)
... 29 more


请给我任何意见,建议...非常感谢,谢谢您的宝贵时间。

[1] https://docs.wso2.com/display/ESB500/VFS+Transport

最佳答案

尝试像这样将参数附加到端点URL。

<address uri="vfs:ftp://ja8irof_ftp:passftp@localhost:21?transport.vfs.MaxRetryCount=0&amp;transport.vfs.ReconnectTimeout=0"/>

关于ftp - WSO2 VFS FTP代理不读取参数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40321878/

10-10 18:00