2017-07-31 226 views
0

程序沒有拋出任何異常,但文件移動到.camel文件夾中。它沒有上傳到服務器位置/ tmp/uta/test1。它也顯示「Upload file ubuntu.png做完了。」。請幫我找出有什麼問題。Apache Camel SFTP文件上傳不起作用

路由器: -

@Component 
public class SampleCamelRouter extends RouteBuilder { 
    @Override 
    public void configure() throws Exception { 
     from("file:C:/Users/Downloads/test") 
     .to("sftp://[email protected]/tmp/uta/test1?password=password"). 
     log("Upload file ${file:name} is complete."); 
    } 
} 

更新的日誌信息: -

route starts.. 
route ends.. 

[0  ] - Apache Camel 2.13.0 (CamelContext: camel-1) is starting 
[4  ] - Tracing is enabled on CamelContext: camel-1 
[5  ] - JMX is enabled 
[370 ] - Loaded 175 type converters 
[662 ] - AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance. 
[662 ] - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html 
[725 ] - Route: route1 started and consuming from: Endpoint[file://C:/Users/Downloads/test] 
[725 ] - Total 1 routes, of which 1 is started. 
[744 ] - Apache Camel 2.13.0 (CamelContext: camel-1) started in 0.730 seconds 
[31453 ] - ID-B20GPF2-59231-1501554606358-0-2 >>> (route1) from(file://C:/Users/Downloads/test) --> sftp://[email protected]/tmp/uta/test1?password=xxxxxx <<< Pattern:InOnly, Headers:{CamelFileName=cron.png, CamelFileNameOnly=cron.png, CamelFileRelativePath=cron.png, CamelFileAbsolute=true, CamelFileLength=4214, CamelFileAbsolutePath=C:\Users\Downloads\test\cron.png, breadcrumbId=ID-B20GPF2-59231-1501554606358-0-1, CamelFileLastModified=1497248004376, CamelFileParent=C:\Users\Downloads\test, CamelFilePath=C:\Users\Downloads\test\cron.png, CamelFileNameConsumed=cron.png}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[C:\Users\Downloads\test\cron.png]] 
[31649 ] - JSCH -> Connecting to 102.108.99.100 port 22 
[31685 ] - JSCH -> Connection established 
[31703 ] - JSCH -> Remote version string: SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 
[31703 ] - JSCH -> Local version string: SSH-2.0-JSCH-0.1.50 
[31703 ] - JSCH -> CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 
[33657 ] - JSCH -> aes256-ctr is not available. 
[33657 ] - JSCH -> aes192-ctr is not available. 
[33657 ] - JSCH -> aes256-cbc is not available. 
[33657 ] - JSCH -> aes192-cbc is not available. 
[33657 ] - JSCH -> arcfour256 is not available. 
[33658 ] - JSCH -> CheckKexes: diffie-hellman-group14-sha1 
[34313 ] - JSCH -> SSH_MSG_KEXINIT sent 
[34314 ] - JSCH -> SSH_MSG_KEXINIT received 
[34314 ] - JSCH -> kex: server: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 
[34314 ] - JSCH -> kex: server: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 
[34314 ] - JSCH -> kex: server: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] 
[34314 ] - JSCH -> kex: server: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] 
[34314 ] - JSCH -> kex: server: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 
[34314 ] - JSCH -> kex: server: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 
[34314 ] - JSCH -> kex: server: none,[email protected] 
[34314 ] - JSCH -> kex: server: none,[email protected] 
[34314 ] - JSCH -> kex: server: 
[34314 ] - JSCH -> kex: server: 
[34314 ] - JSCH -> kex: client: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1 
[34314 ] - JSCH -> kex: client: ssh-rsa,ssh-dss 
[34314 ] - JSCH -> kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc 
[34315 ] - JSCH -> kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc 
[34315 ] - JSCH -> kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96 
[34315 ] - JSCH -> kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96 
[34315 ] - JSCH -> kex: client: none 
[34315 ] - JSCH -> kex: client: none 
[34315 ] - JSCH -> kex: client: 
[34315 ] - JSCH -> kex: client: 
[34315 ] - JSCH -> kex: server->client aes128-ctr hmac-sha1 none 
[34315 ] - JSCH -> kex: client->server aes128-ctr hmac-sha1 none 
[34337 ] - JSCH -> SSH_MSG_KEXDH_INIT sent 
[34337 ] - JSCH -> expecting SSH_MSG_KEXDH_REPLY 
[34359 ] - JSCH -> ssh_rsa_verify: signature true 
[34364 ] - JSCH -> Permanently added '102.108.99.100' (RSA) to the list of known hosts. 
[34365 ] - JSCH -> SSH_MSG_NEWKEYS sent 
[34365 ] - JSCH -> SSH_MSG_NEWKEYS received 
[34374 ] - JSCH -> SSH_MSG_SERVICE_REQUEST sent 
[34375 ] - JSCH -> SSH_MSG_SERVICE_ACCEPT received 
[34378 ] - JSCH -> Authentications that can continue: publickey,keyboard-interactive,password 
[34379 ] - JSCH -> Next authentication method: publickey 
[34380 ] - JSCH -> Authentications that can continue: keyboard-interactive,password 
[34380 ] - JSCH -> Next authentication method: keyboard-interactive 
[34396 ] - JSCH -> Authentication succeeded (keyboard-interactive). 
[34904 ] - Connected to sftp://[email protected]:22 
[34904 ] - Connected and logged in to: Endpoint[sftp://[email protected]/tmp/uta/test1?password=xxxxxx] 
[34950 ] - ID-B20GPF2-59231-1501554606358-0-2 >>> (route1) sftp://[email protected]/tmp/uta/test1?password=xxxxxx --> log[Upload file ${file:name} is complete.] <<< Pattern:InOnly, Headers:{CamelFileRelativePath=cron.png, breadcrumbId=ID-B20GPF2-59231-1501554606358-0-1, CamelFileLastModified=1497248004376, CamelFileLength=4214, CamelFileName=cron.png, CamelFileNameConsumed=cron.png, CamelFileNameProduced=tmp/uta/test1/cron.png, CamelFileParent=C:\Users\Downloads\test, CamelFileNameOnly=cron.png, CamelFileAbsolute=true, CamelFilePath=C:\Users\Downloads\test\cron.png, CamelFileAbsolutePath=C:\Users\Downloads\test\cron.png}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[C:\Users\Downloads\test\cron.png]] 
[34950 ] - Upload file cron.png is complete. 

回答

1

默認情況下,駱駝將始終轉到/ home/username/dir,然後打開您提供的目錄路徑。 所以,它會是相對路徑。 您不能直接提供絕對路徑,所以用「/../../tmp/uta/test1」和「逐步=真正的」

爲了更好的見解,你也可以嘗試: runLoggingLevel = TRACE,throwExceptionOnConnectFailed = true和其他選項。

2

的文件移動到.camel子文件夾中運行CAMEL應用在計算機上。這就是駱駝文件組件的工作方式(請參閱移動選項)。

駱駝路線中使用的FTP組件應該上傳文件。所以,你是否檢查過FTP服務器端,如果有文件上傳。您可以檢查來自FTP服務器的日誌。

您還可以嘗試在駱駝應用程序上啓用DEBUG/TRACE日誌記錄以查看正在記錄的內容。

+0

感謝您的回覆,我知道第一個文件將被移動到.camle,但問題是面臨的是它沒有上傳到服務器也沒有error.Please找到更新的TRACE細節。 – sunleo

+0

感謝您的指導來進行調試,但在日誌中,它沒有顯示上傳發生的位置。 – sunleo

0

文件成功上傳到服務器,但位置不同。

Location to route :[email protected]/tmp/uta/test1 
Location routed :[email protected]/home/user/tmp/uta/test1 

它正在用戶主目錄內創建上傳目錄,這是它在預期目錄中不可用的原因。