camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashwin Karpe <aska...@progress.com>
Subject Re: Files ignored on second scan of directory
Date Thu, 11 Feb 2010 15:33:19 GMT

Hi,

Please check out  http://camel.apache.org/file.html
http://camel.apache.org/file.html  section on common gotchas in file and
folder names

The file consumer scans for new files by keeping an internal modified
timestamp of the last consumed file. So if you copy a new file that has an
older modified timestamp, Camel will not pick up this file. This can happen
if you are testing and you copy the same file back to the folder that has
just been consumed. To remedy this, modify the timestamp before copying the
file back.

Cheers,

Ashwin...


JohnMal wrote:
> 
> I am trying to copy files and change their contents based on an incoming
> JMS message.  If the same file name is passed in more then once the
> consumer only picks up the file on the first message.  I have tried
> putting "&idempotent=false" on the url but it made no difference.
> 
> from("activemq:queue:crossBoundaryCouncils").process(new Processor() {
> 	public void process(final Exchange exchange) throws Exception {
> 				
> 	// Get Header properties
> 	Message message = (Message) exchange.getIn();
> 	final String filename = (String) message.getHeader("filename");
> 	final String councilAuthorityCode = (String)
> exchange.getIn().getHeader("councilAuthorityCode");
> 	final String childAuthorityCode = (String)
> exchange.getIn().getHeader("childAuthorityCode");
> 				
> 	String url = getFileRepository().getEndpointUri() +
> "?readLock=none&fileName=" + filename;
> 				
> 	Endpoint endpoint = getContext().getEndpoint(url);
> 	PollingConsumer consumer = endpoint.createPollingConsumer();
> 	consumer.start();
> 	Exchange pollExchange = consumer.receive();
> 	consumer.stop();				
> 	String body = pollExchange.getIn().getBody(String.class);
> 			
> 				
> 	String childFilename = filename; 
> 	childFilename = StringUtils.replace(childFilename, councilAuthorityCode,
> childAuthorityCode);
> 				
> 	String childBody = StringUtils.replace(body, councilAuthorityCode,
> childAuthorityCode);
> 			
> 	exchange.getOut().setHeader("parentFilename",filename);
> 	exchange.getOut().setHeader("childAuthorityCode",childAuthorityCode);
> 	exchange.getOut().setHeader(Exchange.FILE_NAME,childFilename);
> 				
> 	exchange.getOut().setBody(childBody);
> 				
> 	}
>   }).to(file://C://fileserver);
> 
> Camel version 2.1.0 
> WIndows XP
> 
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://old.nabble.com/Files-ignored-on-second-scan-of-directory-tp27547556p27547883.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message