camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas A." <andreasasm...@gmail.com>
Subject Using ConsumerTemplate to fetch files.
Date Tue, 14 Dec 2010 14:47:10 GMT

Hi

I'm trying to do a set up where I use a Spring Trigger to schedule the
trigging of a method that fetches a batch of files from ftp to local files
and then stops.

I don't think I'm quite grasping the way ConsumerTemplate works. When I do
as below the first run works, but the subsequent runs will fail, seemingly
when files run again are of the same name. I get cannot rename exceptions.
Am I experiencing competing consumers here or what? What is the correct way
of achieving what I want?

Would it make more sense to just use the  FTPSClient manually combined with
a Spring Trigger for this?

@Autowired
private ProducerTemplate producer;

@Autowired
private ConsumerTemplate consumer;

public void retrieveStatusFiles() throws Exception {		
	String ftpsUri =
"ftp:localhost:1981/inbox?consumer.delay=1h&username=camel&password=camel123&move=.done";
	String fileUri = "file:{{path.in}}";

	consumer.start();

	while(true) {
		Exchange ex = consumer.receive(ftpsUri, 5000);
		if(ex != null) {
			logger.info("Fetching file: " + ex.getIn().getHeader("CamelFileName"));
			producer.send(fileUri, ex);
		}
		else if (ex == null) {
			consumer.stop();
			break;
		}
	}
}
-- 
View this message in context: http://camel.465427.n5.nabble.com/Using-ConsumerTemplate-to-fetch-files-tp3304671p3304671.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message