0

I want to use filterFile inside my camel route.

I have route like this:

from(String.format("sftp://%s@%s:%d/%s?password=%s&delete=true&readLock=changed&delay=%s,
                systemSettingsService.getSystemSettings().getSftpUserName(),
                systemSettingsService.getSystemSettings().getSftpHost(),
                systemSettingsService.getSystemSettings().getSftpPort(),
                systemSettingsService.getSystemSettings().getSftpSourcePathDestWorking(),
                systemSettingsService.getSystemSettings().getSftpPassword(),
                systemSettingsService.getSystemSettings().getSftpPollPeriod()))...

I have read file2 doc

Here is written:

Camel 2.18: Filters the file based on Simple language. For example to filter on file size, you can use ${file}:size > 5000.

But I don't understand where should I use this simple language.

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

1 Answers1

3

I think the docs have made a typo. It would probably look something like this: from(String.format("sftp://%s@%s:%d/%s?filterFile=$simple{file:size} > 5000&delete=true..."))

Erik Karlstrand
  • 1,479
  • 9
  • 22
  • **Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: sftp://missftp@192.111.11.111:22/destWorking?delay=5000&delete=true&fileFilter=%24%7Bfile%3Asize%7D+%3E+5000&password=pass&readLock=changed due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{fileFilter=${file:size} > 5000}]** – gstackoverflow Nov 29 '17 at 08:50
  • Sorry, I confused File language with Simple language. I've edited my answer to use simple. Try that and see if it works. – Erik Karlstrand Nov 29 '17 at 09:47
  • **Failed to resolve endpoint: sftp://mysftp@192.111.11.111:22/destWorking?delay=5000&delete=true&fileFilter=%24simple%7Bfile%3Asize%7D%3E5000&password=pass&readLock=changed due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{fileFilter=$simple{file:size}>5000}]** – gstackoverflow Nov 29 '17 at 14:22
  • Are you certain that you're using Camel 2.18? Can you add your pom to your question? – Erik Karlstrand Nov 29 '17 at 14:33
  • I use camel 2.20 – gstackoverflow Nov 29 '17 at 14:40
  • compile "org.apache.camel:camel-spring-boot-starter:${CAMEL_VERSION}" compile "org.apache.camel:camel-ftp-starter:${CAMEL_VERSION}" – gstackoverflow Nov 29 '17 at 14:41
  • **CAMEL_VERSION = "2.20.0"** – gstackoverflow Nov 29 '17 at 14:41
  • I see now that I accidentally typed "fileFilter" instead of the correct attribute name "filterFile". I've tried it and it at least doesn't complain. See my updated answer. I'm very sorry. Also, make sure you have spaces surrounding the operator. According to the docs that is mandatory. – Erik Karlstrand Nov 29 '17 at 15:23
  • **&filterFile=$simple{file:size} > 5000** is working – gstackoverflow Nov 29 '17 at 16:13
  • Also it would be desired to have callback if filter fires – gstackoverflow Nov 29 '17 at 16:15