You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by BAnanth <bh...@wipro.com> on 2013/10/31 11:15:23 UTC

Camel-FTP - retrieving the files tranferred and updating DB

Hi,

I have  the following requirement  

a. I have to transfer a file between two FTP servers. The URI's are
dynamically created.  (This has been done)
b. Upon the successful transfer, I need to update the database with all the
files that have been succesfully transferred.
b.1 The DB table has the following structure id,filename,
fromLocation,transferStatus,toLocation,timestamp
c. Upon Exception the same has to be captured in the database.
(transferStatus column to be updated)

The snippet of the 'configure' method of the 'RouteBuilder' class is
displayed below. (from, to etc are the parameters passed and refer to the
FTP from URI and to URI respectively)

/public void configure() throws Exception {
                String successQry =
FTPDAOHelper.createQueryToInsertRecordInFileHistory("hardcodedfileName-how
to get", from, FTPConstants.FTP_SUCCESSFUL, to, channelId);
               String failedQry =
FTPDAOHelper.createQueryToInsertRecordInFileHistory("hardcodedfileName-how
to get", from, FTPConstants.FTP_FAILED, to, channelId);
			   onCompletion().onCompleteOnly().log("Fully
Complete").setBody().constant(successQry).to("jdbc:dataSource");
			  
onCompletion().onFailureOnly().log("Failed").setBody().constant(failedQry).to("jdbc:dataSource");
              
from(from).to(to).setBody().constant(successQry).to("jdbc:dataSource");
}/

I am facing the following problems,
a. The success qry and failure qry are always fixed. Even though I am
generating a unique UUID for file history table,the query generated uopon
the execution always inserts the same record again and again.
b. What could be the alternate approach (other than onComplete()). 
c. How do I get the file names and other parameters of the file from the
exchange?

Thanks and Regards,
Bhavani




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-FTP-retrieving-the-files-tranferred-and-updating-DB-tp5742443.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel-FTP - retrieving the files tranferred and updating DB

Posted by contactreji <co...@gmail.com>.
Hi Bhavani

You can retrieve the file name using camel simple expression ${file:name} if
the file is in the body part of the exchange.
Reference:
jboss-fuse-6.0.0.redhat-024\examples\cbr\src\main\resources\OSGI-INF\blueprint\cbr.xml


Reji  



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-FTP-retrieving-the-files-tranferred-and-updating-DB-tp5742443p5742448.html
Sent from the Camel - Users mailing list archive at Nabble.com.