camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: repeated reading from read-only directory (noop=true + idempotent=false)
Date Wed, 20 May 2015 17:14:43 GMT
Hi

Probably better to just use the java file api to get a list of files

Something in the order of
String[] names = new File(dir).listNames();



On Wed, May 20, 2015 at 5:20 PM, martin.vich <mejlnaspam@seznam.cz> wrote:
> Hi,
>
> I am using polling consumer pattern to read all files in defined directory :
>
> public List<GenericFile> scanFolder(String folder) {
> List<GenericFile> result = new ArrayList<GenericFile>();
> String endpointUrl  = "file:////" + folder +
> "?sendEmptyMessageWhenIdle=true&noop=true"
> PollingConsumer pConsumer =
> camelContext.getEndpoint(endpointUrl).createPollingConsumer();
>
> pConsumer.start();
>
> GenericFile<File> gFile;
>
>  do {
>      Exchange ex = pConsumer.receive(SCAN_TIMEOUT);
>      gFile = (GenericFile<File>) ex.getIn().getBody();
>      if(gFile != null) {
>          result.add(gFile);
>      }
>   } while(gFile != null); //empty message is sent when endpoint is idle
>
>  pConsumer.stop();
>
> }
>
> This works fine but as I am calling this method repeatedly Camel caches all
> files in fileRepository (noop=true enforces idempotent=true) and result is
> empty. I am using noop=true because this needs to work with read-only
> filesystem. Is there a better way how to create 'folder scanner' using
> polling consumer pattern which will read full folder content eachtime ?
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/repeated-reading-from-read-only-directory-noop-true-idempotent-false-tp5767338.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Mime
View raw message