You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "calamita.agostino@libero.it" <ca...@libero.it> on 2013/01/21 10:10:36 UTC

Sinchronize a route with JPA and a route with SFTP component

Hi,
I'm new to Apache Camel.
I'm trying to use  Camel to convert some records from a db table to a csv 
file.

After csv file creation, with another route, I will send it by beans sftp 
camel component.

The route user is:  

	  from("jpa:com.italtel.esc.db.synchro.ClientTableEntity?
consumeDelete=true&maximumResults=1000&maxMessagesPerPoll=5000&delay=120000&consumeLockEntity=false")
       	  .process( new ClientTableToCSVProcessor())
          .to("file://d:/test?fileExist=Append&fileName=report-${header.
DateHourMinute}.csv");

Field ${header.DateHourMinute} will contain date hour minute of operation, so 
I have different files for every polling.

With this route 
        from("file://d:/test").to("sftp://192.168.56.101/orders?
username=myuser&password=mypass");

I send csv files.

My question is: I can I discover that first route has finished the polling ? I 
tried with 1000 records and I saw the csv files is created at the first 
message/record. In this way, the second 
route will send a 'partial' file.
I also tried with doneFileName parameter, but also in this way doneFile is 
created at the first record.

I tried also with notification, but I didn't find an event that signal the end 
of polling.

Ho can I synchronize the routes ?

Thanks.

  

Re: Sinchronize a route with JPA and a route with SFTP component

Posted by Henryk Konsek <he...@gmail.com>.
Hi,

> I can I discover that first route has finished the polling ?

JPA consumer works in a batch [1] mode. It means that you can refer to
the following exchange properties in your route:
* CamelBatchSize
* CamelBatchIndex
* CamelBatchComplete

You are interested in the last one (which will be true only for the
last message in the batch).

Laters.

[1] http://camel.apache.org/batch-consumer.html

--
Henryk Konsek
http://henryk-konsek.blogspot.com