2016-07-31 28 views
0

我用在我的項目Spring Integration,我在我的上下文int-ftp:inbound-channel-adapter如下:int-ftp:入站通道適配器應該在幾分鐘的工作後重新啓動?

<int-ftp:inbound-channel-adapter id="test-inbound-channel-adapter" 
            channel="tmp-channel" 
            session-factory="ftp-Session" 
            auto-create-local-directory="true" 
            delete-remote-files="true" 
            auto-startup="${ftp.active}" 
            filename-regex="my regex ...." 
            remote-directory="${ftp.input.path}" 
            remote-file-separator="/" 
            local-filename-generator-expression="@fileNameGenerator.generateNameBy('test',#this)" 
            temporary-file-suffix=".writing" 
            local-directory="${backupRootPath}/test/tmp//"> 
     <int:poller fixed-rate="10000"/> 
    </int-ftp:inbound-channel-adapter> 

它的正常工作,但與FTP服務器的工作和系統的幾分鐘後不工作應該是重啓,錯誤日誌如下:

2016-07-31 17:11:08.381 ERROR 2980 --- [sk-scheduler-10] o.s.integration.handler.LoggingHandler : org.springframework.messaging.MessagingException: Problem occurred while synchronizing remote to local directory; nested exception is org.springframework.messaging.MessagingException: Failure occurred while copying from remote to local directory; nested exception is java.net.SocketTimeoutException: Read timed out 
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:266) 
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:193) 
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:59) 
    at org.springframework.integration.endpoint.AbstractMessageSource.receive(AbstractMessageSource.java:134) 
    at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:175) 
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:224) 
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:57) 
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:176) 
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:173) 
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:330) 
    at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55) 
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) 
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51) 
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:324) 
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) 
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) 
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: org.springframework.messaging.MessagingException: Failure occurred while copying from remote to local directory; nested exception is java.net.SocketTimeoutException: Read timed out 
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.copyFileToLocalDirectory(AbstractInboundFileSynchronizer.java:295) 
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer$1.doInSession(AbstractInboundFileSynchronizer.java:234) 
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer$1.doInSession(AbstractInboundFileSynchronizer.java:223) 
    at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:410) 
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:223) 
    ... 22 more 
Caused by: java.net.SocketTimeoutException: Read timed out 
    at java.net.SocketInputStream.socketRead0(Native Method) 
    at java.net.SocketInputStream.read(SocketInputStream.java:150) 
    at java.net.SocketInputStream.read(SocketInputStream.java:121) 
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284) 
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326) 
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) 
    at java.io.InputStreamReader.read(InputStreamReader.java:184) 
    at java.io.BufferedReader.fill(BufferedReader.java:161) 
    at java.io.BufferedReader.read(BufferedReader.java:182) 
    at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:58) 
    at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:314) 
    at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:294) 
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:483) 
    at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:821) 
    at org.apache.commons.net.ftp.FTPClient._retrieveFile(FTPClient.java:1854) 
    at org.apache.commons.net.ftp.FTPClient.retrieveFile(FTPClient.java:1845) 
    at org.springframework.integration.ftp.session.FtpSession.read(FtpSession.java:81) 
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.copyFileToLocalDirectory(AbstractInboundFileSynchronizer.java:288) 
    ... 26 more 

如何解決?

在此先感謝

+0

這沒有意義。請分享更多的症狀,如堆棧跟蹤,日誌,甚至可以在本地播放......或者這可能會導致您的FTP服務器限制和某些選項在您的策略中爲您的客戶開啓 –

+0

謝謝@ArtemBilan回覆我,該帖子已被編輯 –

回答

1

嘗試自定義您的DefaultFtpSessionFactory。例如客戶端模式:

/** 
* ACTIVE_LOCAL_DATA_CONNECTION_MODE = 0 <br> 
* A constant indicating the FTP session is expecting all transfers 
* to occur between the client (local) and server and that the server 
* should connect to the client's data port to initiate a data transfer. 
* This is the default data connection mode when and FTPClient instance 
* is created. 
* PASSIVE_LOCAL_DATA_CONNECTION_MODE = 2 <br> 
* A constant indicating the FTP session is expecting all transfers 
* to occur between the client (local) and server and that the server 
* is in passive mode, requiring the client to connect to the 
* server's data port to initiate a transfer. 
* 
* @param clientMode The client mode. 
*/ 
public void setClientMode(int clientMode) { 

還有其他的選擇有關超時:

/** 
* Set the connect timeout for the socket. 
* @param connectTimeout the timeout 
*/ 
public void setConnectTimeout(int connectTimeout) { 
    this.connectTimeout = connectTimeout; 
} 

/** 
* Set the (socket option) timeout on the command socket. 
* @param defaultTimeout the timeout. 
*/ 
public void setDefaultTimeout(int defaultTimeout) { 
    this.defaultTimeout = defaultTimeout; 
} 

/** 
* Set the (socket option) timeout on the data connection. 
* @param dataTimeout the timeout. 
*/ 
public void setDataTimeout(int dataTimeout) { 
    this.dataTimeout = dataTimeout; 
} 

當然,這將是更好的與你的FTP服務器進行協商,以確定爲什麼它不喜歡你的連接,放下它們。

+0

請讓我們知道真正的問題 –

+0

謝謝@ArtemBilan支持我,我看到'vsftp'登錄FTP服務器,當我通過'int-ftp發送命令:inbound-通道適配器「創建與服務器的新連接,幾分鐘後,服務器連接太多了,這可能會導致我的問題? –

相關問題