camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fachhoch <fachh...@gmail.com>
Subject Re: read all files in folder
Date Fri, 10 Jun 2011 23:20:55 GMT
thank u very much , I also tried a simple approach it worked but not sure if 
it is right please tell  me if it is right , what I did is  call
convertBodyTo(String.class)  and I noticed exchange has headers and it had
file path filename and some other values so I just called get header  
Exchange.FILE_NAME it worked .I get the body and   file name of my file.
here is the code

public class MyRouteBuilder extends RouteBuilder {

	
    public void configure() {
    
from("file://e:/u01/oracle/NEW_NEAR_FILES/?delay=60000&move=../PROCESSED_NEAR_FILES")
    			.convertBodyTo(String.class)
    		
//.aggregate(constant(true)).completionFromBatchConsumer().groupExchanges()
    		
.aggregate(constant(true)).completionSize(10).completionTimeout(10000L).groupExchanges() 
    			.process(new FileProcessor())
    			
    	;

    }

    public static class FileProcessor implements  Processor {
		@Override
		public void process(Exchange exchange) throws Exception {
			System.out.println("from process");
			ArrayList<Exchange> grouped =
exchange.getProperty(Exchange.GROUPED_EXCHANGE, ArrayList.class); 
			for(Exchange exch :grouped){
				System.out.println(exch.getIn().getBody(String.class));
				System.out.println(exch.getIn().getHeader(Exchange.FILE_NAME));
//				File file=exch.getIn().getBody(File.class);
//				System.out.println(exch.getProperty(Exchange.FILE_LOCAL_WORK_PATH));
//				//byte[]  filebytes=IOUtils.toByteArray(new FileInputStream(file));
//				System.out.println("name"+file.getName());
			}
		}
    }
}



--
View this message in context: http://camel.465427.n5.nabble.com/read-all-files-in-folder-tp4474104p4477531.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message